:root {
  --primary:      #012653;
  --primary-lt:   #023a7a;
  --accent:       #E21105;
  --dark:         #151821;
  --white:        #FFFFFF;
  --bg:           #f0f2f7;
  --surface:      #FFFFFF;
  --border:       #dde2ed;
  --text:         #151821;
  --text-muted:   #6b7280;
  --sidebar-w:    240px;
  --radius:       12px;
  --shadow:       0 1px 3px rgba(1,38,83,.08), 0 4px 16px rgba(1,38,83,.06);
  --shadow-lg:    0 8px 32px rgba(1,38,83,.16);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ── LOGIN ─────────────────────────────────────── */
body.is-login { background: var(--dark); min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.login-bg { position: fixed; inset: 0; background: linear-gradient(135deg, var(--dark) 0%, var(--primary) 100%); z-index: 0; }
.login-grid { position: fixed; inset: 0; z-index: 0; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 40px 40px; }
.login-wrap { position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { background: var(--accent); color: #fff; font-family: 'Syne', sans-serif; font-weight: 800; display: flex; align-items: center; justify-content: center; border-radius: 10px; width: 38px; height: 38px; font-size: 13px; letter-spacing: .5px; }
.brand-mark.lg { width: 50px; height: 50px; font-size: 17px; border-radius: 12px; }
.brand-name { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 20px; color: #fff; }
.brand-sub { font-size: 12px; color: rgba(255,255,255,.45); margin-top: 2px; }
.login-card { background: var(--white); border-radius: 18px; padding: 36px 32px; width: 100%; box-shadow: var(--shadow-lg); }
.login-card h1 { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 24px; color: var(--primary); margin-bottom: 4px; }
.login-desc { color: var(--text-muted); margin-bottom: 22px; font-size: 13px; }
.login-footer { color: rgba(255,255,255,.25); font-size: 12px; }

/* ── APP LAYOUT ────────────────────────────────── */
.app-wrap { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--primary); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.sidebar-brand { padding: 18px 16px; display: flex; align-items: center; gap: 10px; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 8px; color: rgba(255,255,255,.55); cursor: pointer; font-size: 13.5px; font-weight: 500; transition: all .15s; text-decoration: none; }
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.09); color: rgba(255,255,255,.9); }
.nav-item.active { background: var(--accent); color: #fff; }
.sidebar-user { padding: 14px; display: flex; align-items: center; gap: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.user-avatar { background: var(--accent); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; width: 34px; height: 34px; }
.user-info { flex: 1; min-width: 0; }
.user-name { color: #fff; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,.4); font-size: 11px; text-decoration: none; transition: color .15s; }
.user-role:hover, .active-role { color: rgba(255,255,255,.75) !important; }
.btn-logout { background: none; border: none; cursor: pointer; color: rgba(255,255,255,.35); padding: 4px; border-radius: 5px; transition: color .15s; display: flex; }
.btn-logout:hover { color: var(--accent); }
.btn-logout svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; min-height: 100vh; }

/* ── VIEW HEADER ───────────────────────────────── */
.view-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.view-header h2 { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 700; color: var(--primary); }
.view-header p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── CARDS ─────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { margin-bottom: 16px; }
.card-header h3 { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--primary); }

/* ── STATS ─────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; }
.stat-icon.blue { background: #e8f0fb; color: var(--primary); }
.stat-icon.green { background: #eaf6ee; color: #16a34a; }
.stat-icon.red { background: #fdeaea; color: var(--accent); }
.stat-icon.yellow { background: #fff8e1; color: #d97706; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); }
.dash-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-bottom .card { padding: 20px; }
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--bg); border-radius: 8px; }
.recent-name { font-weight: 500; font-size: 13px; }
.recent-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.ri-badges { display: flex; gap: 6px; }
.quality-wrap { display: flex; align-items: center; justify-content: space-around; margin-top: 8px; }
.quality-ring { position: relative; width: 120px; height: 120px; }
.quality-ring svg { width: 120px; height: 120px; }
.quality-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 700; color: var(--primary); }
.quality-legend { display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.green { background: #16a34a; }
.dot.red { background: var(--accent); }

/* ── IMPORT ────────────────────────────────────── */
.import-area { border: 2px dashed var(--border); border-radius: var(--radius); padding: 56px 24px; text-align: center; cursor: pointer; transition: all .2s; background: var(--surface); margin-bottom: 16px; }
.import-area:hover, .import-area.drag { border-color: var(--primary); background: #f0f4fb; }
.upload-icon { width: 48px; height: 48px; fill: none; stroke: var(--primary); stroke-width: 1.5; margin: 0 auto 14px; display: block; opacity: .35; }
.upload-text { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 600; color: var(--primary); margin-bottom: 6px; }
.upload-sub { color: var(--text-muted); font-size: 13px; }
.format-hint { background: #f0f4fb; border-radius: var(--radius); padding: 14px 18px; border-left: 4px solid var(--primary); margin-bottom: 20px; }
.hint-title { font-weight: 600; color: var(--primary); margin-bottom: 6px; }

/* ── TABLES ────────────────────────────────────── */
.table-wrap { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap th { text-align: left; padding: 11px 16px; background: var(--bg); font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); }
.table-wrap td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:hover td { background: #f8faff; }

/* ── BADGES ────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-ok   { background: #eaf6ee; color: #16a34a; }
.badge-err  { background: #fdeaea; color: var(--accent); }
.badge-warn { background: #fff8e1; color: #d97706; }
.badge-admin { background: #e8f0fb; color: var(--primary); }
.badge-user  { background: var(--bg); color: var(--text-muted); }
.error-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.err-tag { background: #fdeaea; color: var(--accent); padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 500; }

/* ── FORMS ─────────────────────────────────────── */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 5px; }
.field input, .field select, input[type=text], input[type=password], select {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 14px; color: var(--text); background: var(--white);
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.field input:focus, .field select:focus, input[type=text]:focus, input[type=password]:focus, select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(1,38,83,.07);
}
.search-input { padding: 8px 13px; border: 1.5px solid var(--border); border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 13px; outline: none; transition: border-color .15s; width: 220px; background: var(--white); }
.search-input:focus { border-color: var(--primary); }

/* ── BUTTONS ───────────────────────────────────── */
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 10px 20px; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary:hover { background: #c50e04; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(226,17,5,.25); }
.btn-primary.full { width: 100%; padding: 12px; font-size: 15px; justify-content: center; }
.btn-secondary { background: var(--white); color: var(--text); border: 1.5px solid var(--border); padding: 9px 18px; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all .15s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }

/* ── ALERTS ────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #fdeaea; color: var(--accent); border: 1px solid #f9c7c4; }
.alert-ok    { background: #eaf6ee; color: #16a34a; border: 1px solid #bbf0c8; }

/* ── EMPTY STATE ───────────────────────────────── */
.empty-state { padding: 48px; text-align: center; color: var(--text-muted); font-size: 14px; }
.empty-state a { color: var(--primary); font-weight: 500; }

/* ── TOAST ─────────────────────────────────────── */
.toast { position: fixed; bottom: 28px; right: 28px; background: var(--dark); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px; z-index: 9999; box-shadow: var(--shadow-lg); animation: slideUp .2s ease; }
@keyframes slideUp { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: none; } }

/* ── UTILS ─────────────────────────────────────── */
.hidden { display: none !important; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dash-bottom { grid-template-columns: 1fr; }
  .main-content { padding: 20px 16px; }
}
