:root {
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-soft: #f0fdfa;
  --teal-border: #ccfbf1;
  --amber: #d97706;
  --bg: #f2f7f6;
  --surface: #ffffff;
  --text: #0f2926;
  --muted: #64748b;
  --border: #e2ecea;
  --danger: #dc2626;
  --sidebar-w: 244px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ic svg { width: 1em; height: 1em; display: block; }
.hidden { display: none !important; }

/* Login Page */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #0b3b36 0%, #0d9488 55%, #e6f4f1 55%, #f2f7f6 100%);
}
.login-card {
  width: 100%; max-width: 440px;
  background: #fff; border-radius: 22px; padding: 32px 30px;
  box-shadow: 0 24px 60px rgba(15, 76, 70, 0.18);
  border: 1px solid rgba(13, 148, 136, 0.12);
}
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.login-brand img {
  width: 48px; height: 48px; border-radius: 14px; object-fit: cover;
  box-shadow: 0 6px 18px rgba(13,148,136,0.28);
}
.login-brand h1 { font-size: 20px; font-weight: 800; color: var(--text); }
.login-brand p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.quick-accounts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px;
}
.quick-btn {
  border: 1px solid var(--border); background: var(--teal-soft); color: var(--teal-dark);
  padding: 9px 10px; border-radius: 11px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-align: left; transition: all 0.18s;
}
.quick-btn:hover { border-color: var(--teal); background: #ccfbf1; }
.quick-btn small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; font-size: 11px; }

/* App Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, #0b332f 0%, #0f4641 100%);
  color: #e2f3f0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  padding: 20px 18px; display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.09);
}
.sidebar-brand img {
  width: 38px; height: 38px; border-radius: 10px; object-fit: cover;
  border: 1.5px solid rgba(255,255,255,0.28);
  box-shadow: 0 3px 10px rgba(0,0,0,0.22);
}
.sidebar-brand h2 { font-size: 15.5px; font-weight: 800; color: #fff; }
.sidebar-brand span { font-size: 11px; color: #99f6e4; display: block; margin-top: 2px; }

.nav-list { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-section { font-size: 10.5px; color: rgba(255,255,255,0.45); padding: 10px 12px 4px; letter-spacing: 0.6px; }
.nav-item {
  border: none; background: transparent; color: #cce7e3;
  width: 100%; padding: 10px 12px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: left;
  transition: all 0.16s;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active {
  background: #0d9488; color: #fff; font-weight: 700;
  box-shadow: 0 4px 14px rgba(13,148,136,0.35);
}

.sidebar-footer {
  padding: 14px 14px 16px; border-top: 1px solid rgba(255,255,255,0.09);
  display: flex; flex-direction: column; gap: 8px;
}
.user-pill {
  background: rgba(255,255,255,0.08); border-radius: 11px; padding: 10px 11px;
}
.user-pill .name { font-size: 13px; font-weight: 700; color: #fff; }
.user-pill .role { font-size: 11px; color: #5eead4; margin-top: 2px; }

/* Main Content */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; background: #fff; border-bottom: 1px solid var(--border);
  padding: 0 26px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 17px; font-weight: 800; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 22px 26px 40px; max-width: 1380px; width: 100%; }

/* Buttons & Inputs */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 8px 15px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.16s; text-decoration: none;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal-dark); }
.btn-soft { background: var(--teal-soft); color: var(--teal-dark); border-color: var(--teal-border); }
.btn-soft:hover { background: #ccfbf1; }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.input, .select, .textarea {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 9px 12px; font-size: 13.5px; color: var(--text); background: #fff;
  outline: none; font-family: inherit; transition: border-color 0.16s;
}
select.select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  padding-right: 32px !important;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
}
select.select::-ms-expand { display: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,0.12); }
.textarea { min-height: 92px; resize: vertical; line-height: 1.6; }

/* Cards & Stats */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 1024px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-card {
  background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px;
  box-shadow: 0 4px 16px rgba(15, 118, 110, 0.05);
  border-top: 3px solid var(--teal);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.kpi-card.amber { border-top-color: var(--amber); }
.kpi-icon {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: var(--teal-soft); color: var(--teal-dark);
  display: grid; place-items: center; font-size: 18px;
}
.kpi-card.amber .kpi-icon { background: #fef3c7; color: var(--amber); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.kpi-val { font-size: 28px; font-weight: 800; color: var(--text); margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-sub { font-size: 12px; color: var(--teal-dark); margin-top: 5px; white-space: nowrap; }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 3px 12px rgba(15, 118, 110, 0.04); overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; min-width: 165px; height: 36px; line-height: 34px; padding: 0 11px; font-size: 13px; }
.toolbar select.select { padding-right: 32px !important; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 11px 12px; background: #f8fbfa;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid #eef4f3; vertical-align: middle; }
tr:hover td { background: #fbfefe; }
.col-primary { min-width: 210px; }
.col-salary { color: var(--amber); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.action-group { display: flex; flex-wrap: wrap; gap: 6px; min-width: 150px; }
.sidebar-ghost {
  width: 100%; background: rgba(255,255,255,0.09); color: #ccfbf1;
  border: 1px solid rgba(153,246,228,0.24);
}
.sidebar-ghost:hover { background: rgba(255,255,255,0.16); color: #fff; }

.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.b-green { background: #dcfce7; color: #15803d; }
.b-teal { background: #ccfbf1; color: #0f766e; }
.b-amber { background: #fef3c7; color: #b45309; }
.b-gray { background: #f1f5f9; color: #64748b; }
.b-red { background: #fee2e2; color: #b91c1c; }

.thumb-sm { width: 46px; height: 46px; border-radius: 9px; object-fit: cover; border: 1px solid var(--border); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 41, 38, 0.52);
  backdrop-filter: blur(4px); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto;
  background: #fff; border-radius: 20px; box-shadow: 0 25px 70px rgba(0,0,0,0.28);
}
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 16px; font-weight: 800; }
.modal-body { padding: 20px 22px; display: grid; gap: 14px; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-row-2 { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: #334155; }
.req { color: #ef4444; margin-left: 2px; }
.check-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: 12px; background: var(--teal-soft); border: 1px solid var(--teal-border);
  cursor: pointer; font-size: 13px; color: var(--teal-dark); font-weight: 600;
}

.toast {
  position: fixed; top: 20px; right: 24px; z-index: 200;
  background: #0f2926; color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 600; box-shadow: 0 12px 30px rgba(0,0,0,0.22);
  opacity: 0; transform: translateY(-10px); transition: all 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #b91c1c; }

.dash-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .dash-two-col { grid-template-columns: 1fr; } }

/* Mobile Drawer & Responsive Support */
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-toggle-btn, .drawer-close-btn {
  display: none; border: 1px solid var(--border); background: #f8fbfa; color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  align-items: center; justify-content: center; flex-shrink: 0; font-size: 18px;
}
.drawer-close-btn {
  background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); color: #fff;
  width: 32px; height: 32px; font-size: 16px;
}
.drawer-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(11, 51, 47, 0.52);
  backdrop-filter: blur(3px); z-index: 45;
}
.drawer-backdrop.open { display: block; }

@media (max-width: 900px) {
  .menu-toggle-btn, .drawer-close-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform 0.24s ease;
    box-shadow: 12px 0 36px rgba(0, 0, 0, 0.28);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { padding: 0 14px; height: 56px; }
  .topbar-title { font-size: 15px; }
  .page-body { padding: 14px 12px 32px; }
}

@media (max-width: 640px) {
  .login-shell { padding: 14px; }
  .login-card { padding: 24px 18px; border-radius: 18px; }
  .quick-accounts { grid-template-columns: 1fr; }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .kpi-card { padding: 13px 12px; border-radius: 14px; gap: 6px; }
  .kpi-icon { width: 32px; height: 32px; font-size: 15px; border-radius: 9px; }
  .kpi-label { font-size: 11.5px; }
  .kpi-val { font-size: 22px; margin-top: 4px; }
  .kpi-sub { font-size: 10.5px; white-space: normal; }

  .card { border-radius: 14px; }
  .card-header { padding: 13px 14px; gap: 10px; }
  .toolbar { width: 100%; }
  .toolbar .input, .toolbar .select { width: 100%; min-width: 0; flex: 1 1 100%; }
  .card-header > .btn { width: 100%; }

  .table-wrap { -webkit-overflow-scrolling: touch; }
  th { padding: 10px; font-size: 12px; }
  td { padding: 10px; font-size: 12.5px; }

  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .modal { border-radius: 18px 18px 12px 12px; max-height: 92vh; }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px; }
}
