:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e6eaf2;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --green: #059669;
  --green-soft: #e6f7ef;
  --amber: #d97706;
  --amber-soft: #fef3e2;
  --red: #dc2626;
  --red-soft: #fdecec;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -16px rgba(15, 23, 42, 0.22);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: none; }
button { font-family: inherit; }

/* ---------- AUTH ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: #fff; }
.auth-side {
  display: none;
  background: linear-gradient(150deg, #4338ca 0%, #6d28d9 55%, #4f46e5 100%);
  color: #fff;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.auth-side::after {
  content: "";
  position: absolute;
  width: 460px; height: 460px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  right: -160px; bottom: -180px;
}
.auth-side h1 { font-size: 34px; margin: 40px 0 18px; max-width: 420px; }
.auth-side p.lead { color: rgba(255, 255, 255, 0.82); max-width: 400px; margin: 0 0 28px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: rgba(255, 255, 255, 0.94); font-size: 15px; }
.auth-points i { margin-top: 4px; color: #a7f3d0; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 28px 18px; background: var(--bg); }
.auth-card { width: 100%; max-width: 430px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 26px; }
.auth-card h2 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.auth-tabs { display: flex; background: #f1f5f9; border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.auth-tabs a { flex: 1; text-align: center; padding: 9px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.auth-tabs a.active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }
.auth-alt { text-align: center; font-size: 14px; color: var(--muted); margin-top: 18px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-error { background: var(--red-soft); color: #991b1b; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 16px; }

/* ---------- SHELL ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; flex: 0 0 252px; background: #fff; border-right: 1px solid var(--line);
  padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 38px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: var(--ink-2); font-weight: 500; font-size: 14.5px;
}
.nav-link i { width: 18px; text-align: center; color: #94a3b8; }
.nav-link:hover { background: #f3f5fa; color: var(--ink); }
.nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-link.active i { color: var(--brand); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.user-box { display: flex; align-items: center; gap: 10px; padding: 6px 6px 12px; min-width: 0; }
.avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700;
}
.user-meta { min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mail { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 26px 30px 64px; width: 100%; max-width: 1260px; margin: 0 auto; }
.topbar { display: none; }
.tabbar { display: none; }

/* ---------- PAGE HEAD ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin: 5px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.15s ease; background: #eef1f7; color: var(--ink-2);
}
.btn:hover { filter: brightness(0.97); }
.btn:disabled { opacity: 0.65; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 6px 16px -8px rgba(79, 70, 229, 0.9); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: #f8fafc; }
.btn-green { background: var(--green); color: #fff; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; font-size: 14px;
}
.icon-btn:hover { background: #f1f5f9; color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

/* ---------- CARDS / GRID ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; }
.card-head .hint { font-size: 12.5px; color: var(--muted); }
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; }
.kpi-icon.blue { background: var(--brand-soft); color: var(--brand); }
.kpi-icon.green { background: var(--green-soft); color: var(--green); }
.kpi-icon.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.red { background: var(--red-soft); color: var(--red); }
.kpi-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; word-break: break-word; }
.kpi-foot { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 16px; }
.stack { display: grid; gap: 16px; }

/* ---------- BADGES / PROGRESS ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge-blue { background: var(--brand-soft); color: var(--brand); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: #b45309; }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: #f1f5f9; color: var(--muted); }
.progress { height: 8px; border-radius: 999px; background: #eef1f7; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width 0.35s ease; }
.progress.green > span { background: linear-gradient(90deg, #10b981, var(--green)); }
.progress-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 7px; }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-muted { color: var(--muted); }

/* ---------- CHIPS / TABLE ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 11px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data td.right, table.data th.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- PROJECT CARD ---------- */
.project-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.project-card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); color: inherit; transition: 0.18s ease;
}
.project-card:hover { transform: translateY(-2px); border-color: #c7d2fe; box-shadow: 0 12px 30px -18px rgba(79, 70, 229, 0.55); }
.pc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.pc-top h3 { font-size: 16px; }
.pc-client { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-bottom: 13px; }
.pc-money { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; padding-top: 13px; border-top: 1px dashed var(--line); }
.pc-money .lbl { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.pc-money strong { font-size: 14.5px; }

/* ---------- TASKS ---------- */
.task-form { display: flex; gap: 8px; margin-bottom: 14px; }
.task-form input { flex: 1; }
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; max-height: 340px; overflow-y: auto; }
.task { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid #f4f6fb; }
.task:last-child { border-bottom: none; }
.task-title { flex: 1; font-size: 14px; word-break: break-word; }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.check {
  width: 22px; height: 22px; flex: 0 0 22px; border-radius: 7px; border: 1.5px solid #cbd5e1;
  background: #fff; color: transparent; cursor: pointer; display: grid; place-items: center; font-size: 11px; padding: 0;
}
.check.on { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- PAYMENTS ---------- */
.pay-form { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 13px; margin-bottom: 16px; }
.pay-form .btn { margin-top: 10px; }
.pay-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid #f4f6fb; }
.pay-row:last-child { border-bottom: none; }
.pay-amount { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
.pay-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.pay-note { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; word-break: break-word; }
.pay-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.list-scroll { max-height: 420px; overflow-y: auto; }

/* ---------- FORMS ---------- */
.field { display: block; margin-bottom: 13px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #dbe2ee; background: #fff;
  font-size: 14px; font-family: inherit; color: var(--ink); outline: none; transition: 0.15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.13); }
textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ---------- MODAL ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 90;
  display: flex; align-items: flex-start; justify-content: center; padding: 18px; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 560px; box-shadow: 0 30px 60px -20px rgba(15, 23, 42, 0.5); margin: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }

/* ---------- STATES ---------- */
.skeleton-wrap { display: grid; gap: 12px; }
.skeleton-card { height: 96px; border-radius: var(--radius); background: linear-gradient(90deg, #eef1f7 25%, #f6f8fc 37%, #eef1f7 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty { text-align: center; padding: 34px 16px; }
.empty-icon { width: 54px; height: 54px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 21px; margin: 0 auto 14px; }
.empty-icon.danger { background: var(--red-soft); color: var(--red); }
.empty h3 { font-size: 16px; margin-bottom: 6px; }
.empty p { color: var(--muted); font-size: 14px; max-width: 380px; margin: 0 auto 16px; }
.back-link { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.back-link:hover { color: var(--brand); }
.chart-box { position: relative; height: 240px; }
.meta-line { font-size: 13px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.att-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f4f6fb; }
.att-row:last-child { border-bottom: none; }
.att-main { flex: 1; min-width: 0; }
.att-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-sub { font-size: 12px; color: var(--muted); }
.att-progress { width: 96px; flex: 0 0 96px; }
.up-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f4f6fb; }
.up-row:last-child { border-bottom: none; }

/* ---------- RESPONSIVE ---------- */
@media (min-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .auth-wrap { grid-template-columns: 1.05fr 1fr; }
  .auth-side { display: flex; flex-direction: column; justify-content: center; }
  .auth-main { padding: 40px; }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1.35fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .project-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page-head h1 { font-size: 26px; }
}

@media (max-width: 1023px) {
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40; background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line); padding: 10px 16px; backdrop-filter: blur(8px);
  }
  .topbar .brand { padding: 0; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45; background: #fff;
    border-top: 1px solid var(--line); padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px -14px rgba(15, 23, 42, 0.4);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 10.5px; font-weight: 600; color: var(--muted); padding: 3px 0; border-radius: 10px;
  }
  .tabbar a i { font-size: 17px; }
  .tabbar a.active { color: var(--brand); background: var(--brand-soft); }
  .content { padding: 18px 16px 96px; }
}

@media (max-width: 520px) {
  .kpi-value { font-size: 19px; }
  .page-head h1 { font-size: 20px; }
  .auth-card { padding: 20px; border-radius: 16px; }
  .auth-main { padding: 18px 12px; }
  .card { padding: 15px; }
}
