:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e5ea;
  --text: #1c2030;
  --muted: #6b7185;
  --accent: #6d3fd9;
  --accent-soft: #efe9fc;
  --danger: #c62f3b;
  --danger-soft: #fdecee;
  --success: #1d7f4f;
  --success-soft: #e6f5ec;
  --warning: #a86200;
  --warning-soft: #fdf2e0;
  --info: #2459c4;
  --info-soft: #e8effc;
  --radius: 10px;
  --sidebar: 232px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: #1c1a2e; color: #d9d7e8;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 20px 16px; font-weight: 700; font-size: 1.05rem; color: #fff; letter-spacing: .2px; }
.brand span { color: #b89cff; }
.nav { list-style: none; margin: 0; padding: 4px 10px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: #d9d7e8; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { background: rgba(184,156,255,.18); color: #fff; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav .section { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8a87a3; padding: 16px 12px 6px; }
.nav .soon { opacity: .45; pointer-events: none; }
.nav .soon small { margin-left: auto; font-size: .68rem; border: 1px solid #5a5773; border-radius: 99px; padding: 0 6px; }
.sidebar-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who a { color: #fff; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who small { color: #8a87a3; }
.sidebar-user button { background: none; border: 0; color: #b0adc6; cursor: pointer; padding: 6px; border-radius: 6px; }
.sidebar-user button:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.content { padding: 28px 32px 48px; max-width: 1200px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-body { padding: 18px 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr; }
.stack > * + * { margin-top: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; }
.stat.alert .value { color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; min-height: 38px;
}
.btn:hover { background: #f0f1f4; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #5b31c0; }
.btn-danger { color: var(--danger); border-color: #f1c4c8; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn-link { background: none; border: 0; color: var(--accent); padding: 0; min-height: 0; cursor: pointer; font: inherit; }

.badge {
  display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600;
  background: #eef0f3; color: #4a5064; white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.sidebar .avatar { background: #3b3558; color: #e1d6ff; }
.person { display: inline-flex; align-items: center; gap: 8px; }
.people { display: flex; flex-wrap: wrap; gap: 8px 16px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafafe; }
.table .title { font-weight: 600; color: var(--text); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 20px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--text); }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }

.progress { height: 6px; background: #eceef2; border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

dl.details { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; word-break: break-word; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding-top: 8px; border-top: 1px solid var(--border); }
.form-section:first-child { border-top: 0; padding-top: 0; }
label.lbl { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 11px; border: 1px solid #cfd3db; border-radius: 8px; font: inherit;
  background: #fff; color: var(--text); min-height: 38px;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.input.is-invalid { border-color: var(--danger); }
.error { color: var(--danger); font-size: .85rem; margin-top: 4px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters .input { width: auto; min-width: 160px; }
.filters .search { flex: 1; min-width: 200px; }
.inline-form { display: inline; }
.status-select { padding: 3px 8px; min-height: 30px; font-size: .85rem; width: auto; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 99px; color: var(--muted); font-weight: 500; font-size: .9rem; }
.tabs a:hover { background: #eceef2; text-decoration: none; }
.tabs a.active { background: var(--text); color: #fff; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

.activity-block + .activity-block { margin-top: 16px; }
.overdue { color: var(--danger); font-weight: 600; }
.done .title { text-decoration: line-through; color: var(--muted); }
details.menu { position: relative; }
details.menu summary { list-style: none; cursor: pointer; }
details.menu summary::-webkit-details-marker { display: none; }

.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 5px 11px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); font-size: .9rem; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .disabled { color: var(--muted); }

/* Login */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: #1c1a2e; }
.auth .card { width: 100%; max-width: 380px; }
.auth .brand { color: var(--text); padding: 0 0 4px; font-size: 1.3rem; }
.auth .brand span { color: var(--accent); }

/* Mobile */
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #1c1a2e; color: #fff;
    position: sticky; top: 0; z-index: 20;
  }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
  .topbar .brand { padding: 0; }
  .content { padding: 18px 16px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  dl.details { grid-template-columns: 1fr; gap: 0; }
  dl.details dd { margin-bottom: 10px; }
  .table .hide-sm { display: none; }
  .table th, .table td { padding: 10px 12px; }
  .list li { padding: 12px 16px; flex-wrap: wrap; gap: 8px 10px; }
  .list .grow { flex-basis: 100%; }
  h1 { font-size: 1.3rem; }
}
