/* ─────────────────────────────────────────────────────────────────────────────
   KRB Design System — theme.css
   Aesthetic: Industrial precision. Dark ground, warm amber accent.
   Font: Outfit (display) + DM Mono (data/numbers)
───────────────────────────────────────────────────────────────────────────── */

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

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:         #0d0f14;
  --bg2:        #11141b;
  --surface:    #161b26;
  --surface2:   #1d2333;
  --surface3:   #242b3d;
  --border:     #2a3347;
  --border2:    #354060;

  --accent:     #f5a623;
  --accent-dim: rgba(245,166,35,.15);
  --accent2:    #3b82f6;
  --accent2-dim:rgba(59,130,246,.15);

  --green:      #22c55e;
  --green-dim:  rgba(34,197,94,.12);
  --red:        #ef4444;
  --red-dim:    rgba(239,68,68,.12);
  --yellow:     #eab308;
  --yellow-dim: rgba(234,179,8,.12);

  --text:       #e8eaf2;
  --text2:      #9ba3bb;
  --text3:      #5a6480;

  --font:       'Outfit', sans-serif;
  --mono:       'DM Mono', monospace;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  22px;

  --shadow:     0 4px 24px rgba(0,0,0,.4);
  --shadow-sm:  0 2px 8px  rgba(0,0,0,.3);

  --sidebar-w:  230px;
  --topbar-h:   58px;

  --transition: 0.18s ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body               { height: 100%; }
body {
  font-family:    var(--font);
  background:     var(--bg);
  color:          var(--text);
  font-size:      14px;
  line-height:    1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
#app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  overflow: hidden;
}
#app-shell.hidden { display: none; }
#login-wrap.hidden { display: none; }

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
#sidebar {
  grid-row: 1 / 3;
  background:   var(--surface);
  border-right: 1px solid var(--border);
  display:      flex;
  flex-direction: column;
  overflow-y:   auto;
}

.sidebar-logo {
  padding:      20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display:      flex;
  align-items:  center;
  gap:          10px;
}
.sidebar-logo__mark {
  width: 34px; height: 34px;
  background:    var(--accent);
  border-radius: var(--radius-sm);
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-weight:   800;
  font-size:     16px;
  color:         #000;
  flex-shrink:   0;
}
.sidebar-logo__name  { font-weight: 700; font-size: 15px; line-height: 1.1; }
.sidebar-logo__sub   { font-size: 11px; color: var(--text3); }

.sidebar-user {
  margin:        10px 10px 4px;
  padding:       10px 12px;
  background:    var(--surface2);
  border-radius: var(--radius);
  display:       flex;
  align-items:   center;
  gap:           10px;
}
.sidebar-user__avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background:    var(--accent2);
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-weight:   700;
  font-size:     13px;
  color:         #fff;
  flex-shrink:   0;
}
.sidebar-user__name  { font-size: 13px; font-weight: 600; }
.sidebar-user__role  { font-size: 11px; color: var(--text3); text-transform: capitalize; }

.nav-section {
  padding:        12px 18px 4px;
  font-size:      10px;
  color:          var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight:    600;
}
.nav-item {
  display:       flex;
  align-items:   center;
  gap:           10px;
  padding:       9px 14px;
  margin:        1px 8px;
  border-radius: var(--radius);
  color:         var(--text2);
  font-size:     13.5px;
  font-weight:   500;
  transition:    all var(--transition);
  cursor:        pointer;
  border:        none;
  background:    none;
  width:         calc(100% - 16px);
  text-align:    left;
}
.nav-item:hover        { background: var(--surface2); color: var(--text); }
.nav-item--active      { background: var(--accent-dim); color: var(--accent); }
.nav-item--active .nav-item__icon { color: var(--accent); }
.nav-item__icon        { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  margin-top:   auto;
  padding:      12px 10px;
  border-top:   1px solid var(--border);
}

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
#topbar {
  background:   var(--surface);
  border-bottom: 1px solid var(--border);
  display:      flex;
  align-items:  center;
  justify-content: space-between;
  padding:      0 24px;
  height:       var(--topbar-h);
}
#page-title { font-size: 17px; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ── Page outlet ────────────────────────────────────────────────────────────── */
#page-outlet {
  overflow-y: auto;
  padding:    24px;
  background: var(--bg);
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display:       inline-flex;
  align-items:   center;
  gap:           6px;
  padding:       8px 16px;
  border-radius: var(--radius);
  border:        none;
  font-family:   var(--font);
  font-size:     13px;
  font-weight:   600;
  cursor:        pointer;
  transition:    all var(--transition);
  white-space:   nowrap;
}
.btn-sm    { padding: 5px 12px; font-size: 12px; }
.btn-lg    { padding: 11px 22px; font-size: 15px; }

.btn-primary { background: var(--accent);  color: #000; }
.btn-primary:hover { background: #e09518; }

.btn-blue    { background: var(--accent2);  color: #fff; }
.btn-blue:hover { background: #2563eb; }

.btn-ghost   { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border2); background: var(--surface3); }

.btn-danger  { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,.25); }

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow:      hidden;
}
.card-header {
  padding:       14px 20px;
  border-bottom: 1px solid var(--border);
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  gap:           12px;
}
.card-header h3    { font-size: 14px; font-weight: 700; }
.card-body         { padding: 20px; }
.card-footer       { padding: 12px 20px; border-top: 1px solid var(--border); }

/* ── Stat cards ─────────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       18px 20px;
  position:      relative;
  overflow:      hidden;
}
.stat-card::after {
  content:  '';
  position: absolute;
  inset:    0;
  background: linear-gradient(135deg, rgba(255,255,255,.03) 0%, transparent 60%);
  pointer-events: none;
}
.stat-card__accent {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.stat-card__label  { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-card__value  { font-size: 26px; font-weight: 800; font-family: var(--mono); line-height: 1; }
.stat-card__sub    { font-size: 11px; color: var(--text3); margin-top: 6px; }
.stat-card__icon   { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 32px; opacity: .08; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap  { overflow-x: auto; }
table        { width: 100%; border-collapse: collapse; }
thead th {
  background:    var(--surface2);
  padding:       10px 14px;
  text-align:    left;
  font-size:     11px;
  color:         var(--text3);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight:   600;
  white-space:   nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 11px 14px; font-size: 13px; }
.td-mono  { font-family: var(--mono); font-size: 12px; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display:       inline-block;
  padding:       3px 9px;
  border-radius: 20px;
  font-size:     11px;
  font-weight:   700;
  letter-spacing: .3px;
}
.badge--green   { background: var(--green-dim);  color: var(--green); }
.badge--red     { background: var(--red-dim);    color: var(--red); }
.badge--yellow  { background: var(--yellow-dim); color: var(--yellow); }
.badge--blue    { background: var(--accent2-dim); color: var(--accent2); }
.badge--amber   { background: var(--accent-dim); color: var(--accent); }
.badge--default { background: var(--surface3);  color: var(--text2); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group         { display: flex; flex-direction: column; gap: 5px; }
.form-group label   { font-size: 12px; color: var(--text2); font-weight: 500; }
.form-grid          { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full    { grid-column: 1 / -1; }

.input {
  background:    var(--surface2);
  border:        1px solid var(--border);
  color:         var(--text);
  padding:       9px 12px;
  border-radius: var(--radius);
  font-family:   var(--font);
  font-size:     13px;
  outline:       none;
  transition:    border var(--transition);
  width:         100%;
}
.input:focus      { border-color: var(--accent); }
.input::placeholder { color: var(--text3); }
.input--mono      { font-family: var(--mono); }
select.input option { background: var(--surface); }

/* ── Search bar ─────────────────────────────────────────────────────────────── */
.search-bar {
  display:       flex;
  align-items:   center;
  gap:           8px;
  background:    var(--surface2);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       7px 12px;
  min-width:     200px;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  background: none; border: none; color: var(--text);
  font-family: var(--font); font-size: 13px; outline: none; width: 100%;
}
.search-bar__icon { color: var(--text3); font-size: 15px; flex-shrink: 0; }

/* ── Panel (slide-in) ───────────────────────────────────────────────────────── */
.panel {
  position:   fixed;
  top:        0; right: 0; bottom: 0;
  width:      420px;
  max-width:  95vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index:    200;
  transform:  translateX(100%);
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  display:    flex;
  flex-direction: column;
  overflow-y: auto;
}
.panel--open   { transform: translateX(0); }
.panel-header  { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-header h3 { font-size: 15px; font-weight: 700; }
.panel-body    { padding: 20px; flex: 1; overflow-y: auto; }
.panel-footer  { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.panel-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s ease;
}
.panel-backdrop--show { opacity: 1; pointer-events: all; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(3px);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.modal--open { opacity: 1; pointer-events: all; }
.modal {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-xl);
  padding:       28px;
  width:         500px; max-width: 95vw;
  max-height:    90vh; overflow-y: auto;
  transform:     scale(.96);
  transition:    transform 0.2s ease;
}
.modal-overlay.modal--open .modal { transform: scale(1); }
.modal h2  { font-size: 17px; font-weight: 700; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.krb-toast {
  position:      fixed;
  bottom:        24px; left: 50%;
  transform:     translateX(-50%) translateY(80px);
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       11px 20px;
  font-size:     13px; font-weight: 500;
  z-index:       999;
  opacity:       0;
  transition:    transform 0.25s ease, opacity 0.25s ease;
  white-space:   nowrap;
  box-shadow:    var(--shadow);
}
.krb-toast--show { transform: translateX(-50%) translateY(0); opacity: 1; }
.krb-toast--success { border-color: var(--green); color: var(--green); }
.krb-toast--error   { border-color: var(--red);   color: var(--red); }
.krb-toast--warning { border-color: var(--yellow); color: var(--yellow); }
.krb-toast--info    { border-color: var(--accent2); color: var(--accent2); }

/* ── Loader ─────────────────────────────────────────────────────────────────── */
#krb-loader {
  position: fixed; inset: 0;
  background: rgba(13,15,20,.7);
  backdrop-filter: blur(4px);
  z-index: 998;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
#krb-loader.krb-loader--show { opacity: 1; pointer-events: all; }
.krb-loader__spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.krb-loader__text { font-size: 13px; color: var(--text2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Confirm dialog ─────────────────────────────────────────────────────────── */
#krb-confirm {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#krb-confirm.krb-confirm--show { opacity: 1; pointer-events: all; }
.krb-confirm__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.krb-confirm__box {
  position:      relative;
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       26px;
  width:         360px; max-width: 95vw;
  box-shadow:    var(--shadow);
}
.krb-confirm__title   { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.krb-confirm__msg     { font-size: 13px; color: var(--text2); margin-bottom: 20px; }
.krb-confirm__actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Skeleton ───────────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  height: 14px; width: 80%;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state       { padding: 52px 20px; text-align: center; color: var(--text3); }
.empty-state__icon { font-size: 44px; margin-bottom: 12px; }
.empty-state__title { font-size: 15px; font-weight: 600; color: var(--text2); }
.empty-state__sub  { font-size: 13px; margin-top: 4px; }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; padding: 12px 16px; justify-content: flex-end; }
.page-btn {
  min-width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text2); font-size: 13px; cursor: pointer; font-family: var(--font);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover         { border-color: var(--accent); color: var(--accent); }
.page-btn--active       { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }
.page-btn:disabled      { opacity: .35; cursor: not-allowed; }
.pagination-info        { font-size: 12px; color: var(--text3); margin-right: auto; }

/* ── Text utilities ─────────────────────────────────────────────────────────── */
.text-success { color: var(--green); }
.text-danger  { color: var(--red); }
.text-warning { color: var(--yellow); }
.text-muted   { color: var(--text3); }
.text-accent  { color: var(--accent); }
.text-mono    { font-family: var(--mono); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.fw-bold      { font-weight: 700; }

/* ── Spacing helpers ────────────────────────────────────────────────────────── */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 14px; }
.mb-3 { margin-bottom: 20px; }
.mb-4 { margin-bottom: 28px; }
.mt-auto { margin-top: auto; }
.gap-2 { gap: 10px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.hidden { display: none !important; }

/* ── Login page ─────────────────────────────────────────────────────────────── */
#login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  position: relative;
}
#login-wrap::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(245,166,35,.06) 0%, transparent 70%);
  pointer-events: none;
}
.login-card {
  width: 380px; max-width: 95vw;
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--radius-xl);
  padding:       36px 32px;
  position:      relative;
}
.login-card__logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-card__mark {
  width: 42px; height: 42px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 20px; color: #000;
}
.login-card__title { font-size: 18px; font-weight: 800; }
.login-card__sub   { font-size: 12px; color: var(--text3); }
.login-error {
  background: var(--red-dim); border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius); padding: 10px 14px;
  font-size: 13px; color: var(--red); margin-bottom: 14px;
}
.login-error.hidden { display: none; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr auto;
  }
  #sidebar {
    grid-row: 3;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-top: 1px solid var(--border);
    height: 60px;
  }
  .sidebar-logo, .sidebar-user, .nav-section,
  .nav-item span, .sidebar-footer { display: none; }
  .nav-item { padding: 8px 14px; margin: 4px 2px; }
  .nav-item__icon { font-size: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  #page-outlet { padding: 16px; }
}
