:root {
  --sidebar: #0e2858;
  --sidebar-hover: #1a376e;
  --sidebar-active: #3c8dbc;
  --sidebar-text: #c9d4e8;
  --accent: #3c8dbc;
  --accent-dark: #2f6fa0;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e2e6ee;
  --text: #1f2d3d;
  --muted: #6b7a90;
  --navy: #0e2858;
  --green: #28a745;
  --green-soft: #e6f6ea;
  --amber: #f0ad4e;
  --amber-soft: #fdf3e2;
  --red: #dc3545;
  --red-soft: #fdeaea;
  --blue-soft: #e8f1fa;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 2px 8px rgba(16,24,40,.08);
  --sidebar-w: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ===== Layout shell ===== */
.wrapper { min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--sidebar); color: var(--sidebar-text); z-index: 30;
  display: flex; flex-direction: column; transition: transform .2s;
}
.sidebar-brand {
  height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px;
  font-weight: 800; font-size: 1.15rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo-badge {
  width: 34px; height: 34px; border-radius: 9px; background: var(--sidebar-active);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.sidebar-nav { flex: 1; padding: 14px 0; overflow-y: auto; }
.sidebar-nav .nav-section { padding: 10px 20px 6px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: rgba(201,212,232,.5); }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 20px; margin: 2px 10px;
  border-radius: 8px; color: var(--sidebar-text); font-size: .92rem; font-weight: 500;
  transition: background .15s; cursor: pointer;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-link .ico { font-size: 1.05rem; width: 20px; text-align: center; }
.nav-link .badge-count {
  margin-left: auto; background: var(--red); color: #fff; font-size: .7rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; min-width: 20px; text-align: center;
}
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: .82rem; }
.sidebar-foot .user-mini { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-foot .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--sidebar-active);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700;
}

/* ===== Main area ===== */
.main { margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 20; height: 60px;
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
}
.topbar .page-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.topbar .crumbs { font-size: .8rem; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  position: relative; background: none; border: none; font-size: 1.2rem; padding: 8px;
  border-radius: 8px; transition: background .15s;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--red); border: 2px solid #fff;
}
.hamburger { display: none; background: none; border: none; font-size: 1.3rem; padding: 6px; }

.content { flex: 1; padding: 22px; }

/* ===== Box / cards ===== */
.box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.box-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.box-header h3 { font-size: 1rem; font-weight: 700; }
.box-header .box-tools { display: flex; gap: 8px; }
.box-body { padding: 18px; }

/* ===== Stat cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-sm);
}
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-card .stat-num { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.stat-card .stat-lbl { color: var(--muted); font-size: .8rem; }

.ic-blue { background: var(--blue-soft); }
.ic-green { background: var(--green-soft); }
.ic-amber { background: var(--amber-soft); }
.ic-red { background: var(--red-soft); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 16px; border-radius: 8px; border: none; font-weight: 600; font-size: .88rem;
  transition: background .15s, transform .1s, box-shadow .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #f8d7da; }
.btn-success { background: var(--green); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: .8rem; border-radius: 7px; }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 600; font-size: .88rem; }
.link-btn:hover { text-decoration: underline; }

/* ===== Badges ===== */
.badge { font-size: .72rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: #b8730d; }
.badge.blue { background: var(--blue-soft); color: var(--accent); }
.badge.gray { background: #eef1f5; color: var(--muted); }
.badge.red { background: var(--red-soft); color: var(--red); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  background: none; border: none; color: var(--muted); padding: 11px 16px;
  font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid var(--border);
  color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfd; }

/* ===== List rows ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
}
.row .meta { flex: 1; min-width: 0; }
.row .meta h4 { font-size: .95rem; margin-bottom: 3px; font-weight: 600; }
.row .meta p { color: var(--muted); font-size: .82rem; }
.row .file-icon {
  width: 40px; height: 40px; border-radius: 9px; background: var(--blue-soft);
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0;
}

/* ===== Progress bar ===== */
.progress { height: 8px; background: #e9edf2; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,.5); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--card); border-radius: 12px; padding: 26px;
  width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal h2 { font-size: 1.15rem; margin-bottom: 16px; }
.modal .modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ===== Forms ===== */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; background: #fff; border: 1.5px solid var(--border);
  border-radius: 8px; padding: 9px 12px; color: var(--text); outline: none; font-size: .92rem;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; border-radius: 10px;
  padding: 12px 20px; font-size: .88rem; z-index: 60; box-shadow: var(--shadow);
}
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }

.empty { text-align: center; color: var(--muted); padding: 42px 0; }
.empty .emoji { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ===== Auth ===== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #e8f1fa 0%, #eef0f8 100%); padding: 24px;
}
.auth-card { background: #fff; border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-card .logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.auth-card .logo-badge {
  width: 44px; height: 44px; border-radius: 11px; font-size: 1.4rem; background: var(--navy);
  display: flex; align-items: center; justify-content: center;
}
.auth-card h1 { font-size: 1.3rem; letter-spacing: -.02em; }
.auth-card .sub { color: var(--muted); margin: 6px 0 22px; font-size: .9rem; }
.seg { display: flex; gap: 6px; background: #f0f3f7; border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.seg button {
  flex: 1; padding: 9px; border-radius: 8px; border: none; background: transparent;
  color: var(--muted); font-weight: 600; font-size: .88rem;
}
.seg button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }

/* ===== Landing ===== */
.landing { min-height: 100vh; background: linear-gradient(160deg, #0e2858 0%, #1a376e 55%, #2f6fa0 100%); color: #fff; }
.land-nav { max-width: 1100px; margin: 0 auto; padding: 20px 26px; display: flex; align-items: center; justify-content: space-between; }
.land-nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; }
.land-nav .logo-badge { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.land-hero { max-width: 720px; margin: 0 auto; padding: 70px 24px 50px; text-align: center; }
.land-hero h1 { font-size: clamp(2rem, 5.5vw, 3rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.15; margin-bottom: 16px; }
.land-hero h1 em { font-style: normal; color: #7fb8e6; }
.land-hero p { color: #c9d4e8; font-size: 1.05rem; max-width: 540px; margin: 0 auto 30px; }
.land-features { max-width: 1000px; margin: 0 auto; padding: 0 24px 60px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature-card { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 22px; backdrop-filter: blur(4px); }
.feature-icon { font-size: 1.6rem; margin-bottom: 10px; }
.feature-card h3 { font-size: 1rem; margin-bottom: 6px; }
.feature-card p { color: #c9d4e8; font-size: .86rem; }
.land-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-light { background: #fff; color: var(--navy); font-weight: 700; }
.btn-outline { background: transparent; border: 1.5px solid rgba(255,255,255,.4); color: #fff; }

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .land-features { grid-template-columns: 1fr; }
}
