@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1a2236;
  --muted: #6b7489;
  --border: #e6e9f2;
  --accent: #2f6fed;
  --accent-2: #5b8ef7;
  --green: #18a957;
  --green-bg: #e8f8ee;
  --red: #e4453a;
  --red-bg: #fdeceb;
  --amber: #e2920f;
  --amber-bg: #fdf3e0;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(26, 34, 54, .06);
}

* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
.icon { display: inline-block; vertical-align: middle; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@keyframes rise { from { opacity: 0; transform: translateY(10px);} to { opacity: 1; transform: translateY(0);} }

/* --- Auth pages --- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 28px; animation: rise .4s ease both;
}
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none;
  padding: 11px 18px; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(47,111,237,.3); }
.btn.block { width: 100%; }
.btn.secondary { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn.danger { background: var(--red); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.msg { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.msg.error { background: var(--red-bg); color: var(--red); }
.msg.ok { background: var(--green-bg); color: var(--green); }

/* --- Shell --- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--card); border-right: 1px solid var(--border);
  padding: 22px 14px; display: none; flex-direction: column; position: fixed; top: 0; bottom: 0;
}
@media (min-width: 960px) { .sidebar { display: flex; } .main { margin-left: 230px; } }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; font-weight: 800; font-size: 17px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 14px;
}
.side-nav a:hover { background: var(--bg); color: var(--text); }
.side-nav a.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.side-foot { border-top: 1px solid var(--border); padding-top: 12px; font-size: 13px; color: var(--muted); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; background: var(--card);
  border-bottom: 1px solid var(--border); padding: 12px 18px; position: sticky; top: 0; z-index: 5;
}
@media (min-width: 960px) { .topbar.mobile-only { display: none; } }
.topbar-pill { display: flex; gap: 2px; background: var(--bg); border-radius: 999px; padding: 3px; overflow-x: auto; }
.topbar-pill a { padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.topbar-pill a.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

.main { padding: 22px; max-width: 1180px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); animation: rise .35s ease both; }
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-card-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card-icon.blue { background: #e8f0fe; color: var(--accent); }
.stat-card-icon.green { background: var(--green-bg); color: var(--green); }
.stat-card-icon.red { background: var(--red-bg); color: var(--red); }
.stat-card-icon.amber { background: var(--amber-bg); color: var(--amber); }
.stat-card .num { font-size: 24px; font-weight: 800; }
.stat-card .lbl { font-size: 13px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.gray { background: var(--bg); color: var(--muted); }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.person { display: flex; align-items: center; gap: 10px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .field { margin-bottom: 0; min-width: 160px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.action-row { display: flex; gap: 6px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,24,38,.45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 420px; width: 100%; animation: rise .25s ease both; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
