/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:        #0071e3;
  --brand-dark:   #0058b0;
  --bg:           #f5f5f7;
  --bg-card:      #ffffff;
  --border:       #e5e5e7;
  --text:         #1d1d1f;
  --text-muted:   #6e6e73;
  --success:      #34c759;
  --warning:      #ff9500;
  --danger:       #ff3b30;
  --info:         #007aff;
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --radius:       14px;
  --radius-sm:    8px;
  --shadow:       0 2px 16px rgba(0,0,0,0.07);
  --shadow-md:    0 4px 24px rgba(0,0,0,0.10);
  font-size: 15px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

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

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #1c1c1e;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo img { max-height: 36px; max-width: 100%; }
.sidebar-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  flex: 1; padding: 8px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7); text-decoration: none;
  transition: background 0.15s;
}
.sidebar-user:hover { background: rgba(255,255,255,0.07); color: #fff; text-decoration: none; }

.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-info { display: flex; flex-direction: column; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,0.4); }

.sidebar-logout {
  padding: 8px;
  color: rgba(255,255,255,0.4);
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  display: flex;
}
.sidebar-logout:hover { background: rgba(255,0,0,0.15); color: var(--danger); text-decoration: none; }

/* ── Top Bar ───────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 30px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 17px; font-weight: 700; flex: 1; letter-spacing: -0.3px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* ── Stat Cards ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 32px;
}

.stat-card {
  border-radius: 20px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #fff;
  box-shadow: var(--shadow-md);
}
.stat-card::after {
  content: '';
  position: absolute;
  bottom: -20px; left: -20px;
  width: 150%; height: 60%;
  background: rgba(255,255,255,0.1);
  border-radius: 50% 50% 0 0;
  transform: rotate(-5deg);
}
.stat-card .stat-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  opacity: 0.85; margin-bottom: 8px;
  position: relative; z-index: 1;
}
.stat-card .stat-value {
  font-size: 30px; font-weight: 800;
  letter-spacing: -1px;
  position: relative; z-index: 1;
  line-height: 1;
}
.stat-card .stat-sub {
  font-size: 11px; opacity: 0.7;
  position: relative; z-index: 1;
  margin-top: 6px;
}

.stat-purple  { background: linear-gradient(135deg, #5856d6, #2c299c); box-shadow: 0 10px 20px rgba(88,86,214,0.2); }
.stat-green   { background: linear-gradient(135deg, #34c759, #1d976c); box-shadow: 0 10px 20px rgba(52,199,89,0.2); }
.stat-blue    { background: linear-gradient(135deg, #007aff, #0040dd); box-shadow: 0 10px 20px rgba(0,122,255,0.2); }
.stat-orange  { background: linear-gradient(135deg, #ff9500, #ff5e3a); box-shadow: 0 10px 20px rgba(255,149,0,0.2); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { opacity: 0.88; text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary   { background: var(--brand); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-ghost     { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm        { padding: 6px 12px; font-size: 12px; border-radius: 7px; }
.btn-full      { width: 100%; }
.btn-icon      { padding: 8px; border-radius: 8px; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-muted); margin-bottom: 6px;
}
.field-link { font-size: 12px; font-weight: 500; color: var(--brand); text-transform: none; letter-spacing: 0; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="date"],
input[type="url"], select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #f9f9fb;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,113,227,0.12);
}
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236e6e73' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.field-check { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; font-size: 14px; color: var(--text-muted); }
.field-check label { font-size: 14px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-muted); margin: 0; }
.field-check input[type="checkbox"] { width: auto; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--brand); margin-bottom: 14px; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 10px;
  font-size: 14px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #e6f9ed; border: 1.5px solid #34c759; color: #1a5c2e; }
.alert-error   { background: #fff2f2; border: 1.5px solid #ff3b30; color: #c0392b; }
.alert-warning { background: #fff8e6; border: 1.5px solid #ff9500; color: #7a4a00; }
.alert-info    { background: #e8f0fe; border: 1.5px solid #007aff; color: #003d99; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9f9fb; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  white-space: nowrap;
}
.badge-blue    { background: #007aff12; color: #007aff; border: 1px solid #007aff33; }
.badge-green   { background: #34c75912; color: #27a746; border: 1px solid #34c75933; }
.badge-orange  { background: #ff950012; color: #cc7700; border: 1px solid #ff950033; }
.badge-red     { background: #ff3b3012; color: #cc2200; border: 1px solid #ff3b3033; }
.badge-gray    { background: #8e8e9312; color: #636366; border: 1px solid #8e8e9333; }
.badge-purple  { background: #5856d612; color: #3634a3; border: 1px solid #5856d633; }

/* ── Progress Bar ──────────────────────────────────────────────────────────── */
.progress-wrap { background: var(--border); border-radius: 99px; height: 6px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 99px; background: var(--brand); transition: width 0.4s ease; }
.progress-bar.green  { background: var(--success); }
.progress-bar.orange { background: var(--warning); }

/* ── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; }
.page-header .actions { display: flex; gap: 10px; align-items: center; }

/* ── Auth Pages ────────────────────────────────────────────────────────────── */
.auth-body { background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-wrap { width: 100%; display: flex; align-items: center; justify-content: center; }
.auth-card { background: #fff; border-radius: 20px; padding: 40px; box-shadow: var(--shadow-md); width: 100%; max-width: 400px; border: 1px solid var(--border); }
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo { max-height: 48px; max-width: 100%; margin-bottom: 16px; }
.auth-brand { font-size: 20px; font-weight: 800; color: var(--brand); margin-bottom: 12px; }
.auth-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 4px; }
.auth-header p { color: var(--text-muted); font-size: 14px; }
.auth-footer-info { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); text-align: center; }
.auth-contact { display: flex; flex-direction: column; gap: 4px; align-items: center; margin-bottom: 12px; }
.auth-social  { display: flex; justify-content: center; gap: 16px; }
.auth-social a { color: var(--brand); font-size: 13px; }
.back-link { font-size: 13px; color: var(--text-muted); }

.setup-wrap { max-width: 700px; margin: 0 auto; width: 100%; }

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.empty-state {
  text-align: center; padding: 60px 20px;
  background: var(--bg); border-radius: var(--radius);
  border: 1.5px dashed var(--border);
}
.empty-state p { color: var(--text-muted); font-size: 15px; margin-top: 12px; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 20px 16px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}
