/* ============================================================
   TASK TODO — Premium Design System
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --bg:            #f6f7f9;
  --surface:       #ffffff;
  --surface-2:     #fbfbfc;
  --sidebar-bg:    #0f172a;
  --sidebar-text:  #94a3b8;
  --sidebar-active:#ffffff;

  --text:          #1e293b;
  --text-muted:    #64748b;
  --text-faint:    #94a3b8;

  --border:        #e9edf2;
  --border-strong: #dbe1e8;

  --primary:       #6366f1;
  --primary-600:   #5457e5;
  --primary-soft:  #eef0ff;

  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;
  --purple:        #8b5cf6;

  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;

  --shadow-sm:     0 1px 2px rgba(15,23,42,.06);
  --shadow:        0 4px 14px rgba(15,23,42,.06);
  --shadow-md:     0 8px 24px rgba(15,23,42,.08);
  --shadow-lg:     0 18px 40px rgba(15,23,42,.14);

  --sidebar-w:     256px;
  --header-h:      64px;
  --transition:    .18s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --bg:            #0b1120;
  --surface:       #121a2b;
  --surface-2:     #0f1626;
  --sidebar-bg:    #0a0f1c;
  --text:          #e2e8f0;
  --text-muted:    #94a3b8;
  --text-faint:    #64748b;
  --border:        #1e293b;
  --border-strong: #273449;
  --primary-soft:  #1e2140;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.4);
  --shadow:        0 4px 14px rgba(0,0,0,.35);
  --shadow-md:     0 8px 24px rgba(0,0,0,.45);
  --shadow-lg:     0 18px 40px rgba(0,0,0,.55);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition);
}
.sidebar__brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.2px;
}
.sidebar__brand .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: grid; place-items: center; color: #fff; font-size: 16px;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}
.sidebar__nav { flex: 1; overflow-y: auto; padding: 12px 14px; }
.sidebar__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: #475569; margin: 16px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500; margin-bottom: 2px;
  transition: var(--transition); cursor: pointer;
}
.nav-item i { font-size: 17px; width: 20px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(99,102,241,.22), rgba(99,102,241,.05));
  color: var(--sidebar-active);
  box-shadow: inset 3px 0 0 var(--primary);
}
.nav-item .badge-count {
  margin-left: auto; background: var(--primary); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 20px; font-weight: 600;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; position: sticky; top: 0; z-index: 900;
}
.topbar__search {
  flex: 1; max-width: 420px; position: relative;
}
.topbar__search i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 15px;
}
.topbar__search input {
  width: 100%; height: 40px; padding: 0 14px 0 40px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 13.5px;
  transition: var(--transition);
}
.topbar__search input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft); background: var(--surface);
}
.topbar__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); display: grid; place-items: center;
  cursor: pointer; position: relative; transition: var(--transition); font-size: 17px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%; border: 2px solid var(--surface);
}

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 600;
  font-size: 13px; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }

.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm); transition: var(--transition); }
.user-chip:hover { background: var(--surface-2); }
.user-chip .meta { line-height: 1.2; }
.user-chip .meta strong { display: block; font-size: 13px; }
.user-chip .meta span { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Content ---------- */
.content { padding: 26px 28px; flex: 1; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.4px; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.page-head .spacer { flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card__body { padding: 20px; }
.card__head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card__head h3 { margin: 0; font-size: 15px; font-weight: 650; }

/* Stat cards */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.stat:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat__icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; }
.stat__val { font-size: 26px; font-weight: 750; letter-spacing: -.5px; }
.stat__label { color: var(--text-muted); font-size: 12.5px; font-weight: 500; }
.stat__trend { font-size: 11.5px; font-weight: 600; }
.trend-up { color: var(--success); } .trend-down { color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent;
  cursor: pointer; transition: var(--transition); white-space: nowrap; font-family: inherit;
}
.btn i { font-size: 15px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.28); }
.btn-primary:hover { background: var(--primary-600); box-shadow: 0 6px 16px rgba(99,102,241,.36); }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-light:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 12.5px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
}
.badge .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-soft { background: var(--surface-2); color: var(--text-muted); }

/* status/priority pills get inline color via style attr, but base fallbacks: */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 8px; font-size: 12px; font-weight: 600;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-label .req { color: var(--danger); }
.form-control {
  width: 100%; height: 42px; padding: 0 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13.5px;
  font-family: inherit; transition: var(--transition);
}
textarea.form-control { height: auto; padding: 11px 13px; min-height: 90px; resize: vertical; }
select.form-control { cursor: pointer; }
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-control::placeholder { color: var(--text-faint); }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.input-icon .form-control { padding-left: 40px; }

.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.form-check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ---------- Table ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.tbl tbody tr { transition: var(--transition); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* ---------- Progress ---------- */
.progress { height: 7px; background: var(--border); border-radius: 20px; overflow: hidden; }
.progress__bar { height: 100%; border-radius: 20px; background: var(--primary); transition: width .5s cubic-bezier(.4,0,.2,1); }

/* ---------- Toast ---------- */
#toast-wrap {
  position: fixed; top: 20px; right: 20px; z-index: 5000;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  min-width: 300px; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 13px 16px; display: flex; align-items: flex-start; gap: 12px;
  animation: toastIn .3s cubic-bezier(.4,0,.2,1);
}
.toast.hide { animation: toastOut .25s forwards; }
.toast i { font-size: 19px; margin-top: 1px; }
.toast--success { border-left-color: var(--success); } .toast--success i { color: var(--success); }
.toast--error   { border-left-color: var(--danger); }  .toast--error i   { color: var(--danger); }
.toast--info    { border-left-color: var(--info); }    .toast--info i    { color: var(--info); }
.toast strong { display: block; font-size: 13.5px; }
.toast span { font-size: 12.5px; color: var(--text-muted); }
@keyframes toastIn  { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: var(--transition); z-index: 1200;
}
.dropdown.open .dropdown__menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown__item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; transition: var(--transition);
}
.dropdown__item:hover { background: var(--surface-2); }
.dropdown__item i { font-size: 15px; color: var(--text-muted); width: 18px; }
.dropdown__divider { height: 1px; background: var(--border); margin: 6px 0; }

/* ---------- Empty / skeleton ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty i { font-size: 46px; opacity: .3; margin-bottom: 12px; display: block; }
.empty h4 { margin: 0 0 4px; color: var(--text); font-size: 15px; }
.skeleton { background: linear-gradient(90deg, var(--border) 25%, var(--surface-2) 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-visual {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
  position: relative; overflow: hidden; display: flex; flex-direction: column;
  justify-content: center; padding: 60px; color: #fff;
}
.auth-visual::before, .auth-visual::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08);
}
.auth-visual::before { width: 340px; height: 340px; top: -80px; right: -80px; }
.auth-visual::after  { width: 260px; height: 260px; bottom: -60px; left: -60px; background: rgba(255,255,255,.06); }
.auth-visual .brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; margin-bottom: 40px; position: relative; }
.auth-visual .brand .logo { width: 40px; height: 40px; border-radius: 11px; background: rgba(255,255,255,.15); display: grid; place-items: center; font-size: 20px; }
.auth-visual h2 { font-size: 32px; font-weight: 750; line-height: 1.2; letter-spacing: -.6px; position: relative; margin: 0 0 14px; }
.auth-visual p { font-size: 15px; opacity: .85; position: relative; max-width: 420px; }
.auth-visual .feats { margin-top: 34px; position: relative; display: grid; gap: 14px; }
.auth-visual .feats div { display: flex; align-items: center; gap: 11px; font-size: 14px; opacity: .92; }
.auth-visual .feats i { width: 26px; height: 26px; border-radius: 7px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: 13px; }

.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { font-size: 25px; font-weight: 750; letter-spacing: -.5px; margin: 0 0 6px; }
.auth-box .sub { color: var(--text-muted); margin: 0 0 28px; font-size: 14px; }
.auth-alt { text-align: center; margin-top: 22px; font-size: 13px; color: var(--text-muted); }
.forgot { font-size: 12.5px; color: var(--primary); font-weight: 600; }
.demo-note { margin-top: 20px; padding: 12px 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); font-size: 12px; color: var(--text-muted); }
.demo-note b { color: var(--text); }

/* ---------- Mobile ---------- */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 999; }
.menu-toggle { display: none; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 992px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar.open ~ .sidebar-backdrop, .sidebar-backdrop.show { display: block; }
  .menu-toggle { display: grid; }
  .topbar__search { max-width: none; }
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 18px 16px; }
  .user-chip .meta { display: none; }
}

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Global Search Dropdown ---------- */
.search-results{ position:absolute; top:calc(100% + 8px); left:0; right:0; background:var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow-lg); max-height:420px; overflow-y:auto; z-index:1500; display:none; padding:6px; }
.search-results.open{ display:block; }
.search-results .sr-group{ padding:6px 8px; }
.search-results .sr-head{ font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-faint); padding:6px 10px 4px; }
.search-results .sr-item{ display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:8px; cursor:pointer; font-size:13px; color:var(--text); text-decoration:none; }
.search-results .sr-item:hover{ background:var(--surface-2); }
.search-results .sr-item .sr-ic{ width:30px; height:30px; border-radius:7px; display:grid; place-items:center; background:var(--primary-soft); color:var(--primary); font-size:13px; flex:none; }
.search-results .sr-empty{ padding:22px; text-align:center; color:var(--text-faint); font-size:13px; }
.search-results .sr-code{ margin-left:auto; font-size:11px; color:var(--text-faint); }
