/**
 * opdc-e-maintenance — Design System
 * Obsidian Black · Champagne Gold · Rose Gold
 * Designer & Developer: Ali. Q. Abdulridha
 */

/* ============================== Tokens ============================== */
@property --angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

:root {
  /* Surfaces */
  --bg: #070605;
  --bg-2: #0d0b09;
  --surface: rgba(28, 23, 18, 0.62);
  --surface-strong: rgba(22, 18, 14, 0.92);
  --surface-hover: rgba(40, 33, 25, 0.7);
  --line: rgba(245, 230, 200, 0.09);
  --line-strong: rgba(245, 230, 200, 0.18);

  /* Brand */
  --gold: #e3bc5c;
  --gold-light: #f6dc95;
  --gold-deep: #a97e22;
  --champagne: #f5e6c8;
  --rose: #c98b8f;
  --bronze: #d4a373;

  /* Text */
  --text: #f7f1e6;
  --text-2: #c9bfae;
  --text-3: #8d8374;

  /* Semantic */
  --ok: #5fd39a;
  --ok-bg: rgba(95, 211, 154, 0.12);
  --warn: #f2a65a;
  --warn-bg: rgba(242, 166, 90, 0.13);
  --danger: #f0727a;
  --danger-bg: rgba(240, 114, 122, 0.12);
  --info: #8fb8ff;
  --info-bg: rgba(143, 184, 255, 0.12);

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.85), 0 2px 0 rgba(255, 255, 255, 0.03) inset;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --sidebar-w: 280px;

  --font: 'Almarai', 'Cairo', system-ui, 'Segoe UI', Tahoma, sans-serif;
  --font-latin: 'Cinzel', Georgia, serif;
  --mono: ui-monospace, 'Cascadia Code', Consolas, monospace;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

::selection { background: rgba(227, 188, 92, 0.35); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(227, 188, 92, 0.18); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(227, 188, 92, 0.35); }

/* ============================== Ambient Background ============================== */
.ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.ambient::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 85% -10%, rgba(169, 126, 34, 0.22), transparent 60%),
    radial-gradient(ellipse 60% 50% at 0% 100%, rgba(127, 29, 29, 0.22), transparent 60%),
    radial-gradient(ellipse 100% 80% at 50% 50%, #0f0c09 0%, var(--bg) 70%);
}
.ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(245, 230, 200, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245, 230, 200, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 30%, black 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, black 20%, transparent 75%);
}
.ambient .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.45;
  animation: orbDrift 26s ease-in-out infinite alternate;
}
.ambient .orb.o1 { width: 38vmax; height: 38vmax; top: -12vmax; left: 20%; background: radial-gradient(circle, rgba(227, 188, 92, 0.22), transparent 65%); }
.ambient .orb.o2 { width: 30vmax; height: 30vmax; bottom: -10vmax; right: 10%; background: radial-gradient(circle, rgba(201, 139, 143, 0.18), transparent 65%); animation-duration: 32s; animation-delay: -8s; }
@keyframes orbDrift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-5vmax, 4vmax) scale(1.12); }
}

/* ============================== App Shell ============================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset-block: 0;
  right: 0;
  width: var(--sidebar-w);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(20, 16, 12, 0.92), rgba(10, 8, 6, 0.96));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--line);
  transition: transform 0.45s var(--ease);
}
.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(227, 188, 92, 0.6), transparent);
  opacity: 0.6;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--line);
}
.brand-logo {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(from var(--angle), var(--gold-light), var(--rose), var(--gold), var(--bronze), var(--gold-light));
  animation: spinAngle 6s linear infinite;
  box-shadow: 0 0 22px rgba(227, 188, 92, 0.35);
}
.brand-logo img { width: 100%; height: 100%; border-radius: 50%; object-fit: contain; background: #0a0806; padding: 3px; }
.brand-text strong { display: block; font-size: 0.86rem; font-weight: 800; line-height: 1.35; }
.brand-text span { font-family: var(--font-latin); font-size: 0.66rem; letter-spacing: 0.16em; color: var(--gold); font-weight: 700; }

.nav { flex: 1; overflow-y: auto; padding: 18px 14px; }
.nav-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-3);
  letter-spacing: 0.06em;
  padding: 0 12px 10px;
}
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin-bottom: 4px;
  border-radius: 14px;
  color: var(--text-2);
  font-weight: 700;
  font-size: 0.86rem;
  transition: background 0.25s, color 0.25s, transform 0.25s var(--ease);
}
.nav-link .ico { width: 19px; height: 19px; opacity: 0.8; transition: transform 0.3s var(--spring); }
.nav-link:hover { background: rgba(245, 230, 200, 0.05); color: var(--text); }
.nav-link:hover .ico { transform: scale(1.12); }
.nav-link.active {
  color: var(--gold-light);
  background: linear-gradient(270deg, rgba(227, 188, 92, 0.18), rgba(227, 188, 92, 0.03));
  box-shadow: inset 0 0 0 1px rgba(227, 188, 92, 0.2);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  right: -14px;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}
.nav-link.active .ico { opacity: 1; color: var(--gold); }
.nav-link .count {
  margin-inline-start: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid rgba(242, 166, 90, 0.3);
}

.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); }
.server-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(245, 230, 200, 0.03);
  border: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--text-2);
  margin-bottom: 10px;
}
.watermark { text-align: center; font-size: 0.66rem; color: var(--text-3); letter-spacing: 0.04em; direction: ltr; }
.watermark b { color: var(--gold); font-weight: 700; }

.main { flex: 1; margin-right: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  background: rgba(9, 7, 6, 0.72);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; }
.crumbs { font-size: 0.7rem; color: var(--text-3); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.crumbs .ico { width: 12px; height: 12px; }
.topbar-title h1 { font-size: 1.35rem; font-weight: 800; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: rgba(245, 230, 200, 0.04);
  border: 1px solid var(--line);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.25s var(--ease);
}
.icon-btn:hover { color: var(--gold-light); border-color: rgba(227, 188, 92, 0.35); background: rgba(227, 188, 92, 0.08); }
.icon-btn .ico { width: 19px; height: 19px; }
.icon-btn .dot {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px var(--bg), 0 0 10px var(--gold);
}
.menu-toggle { display: none; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 14px;
  border-radius: 15px;
  background: rgba(245, 230, 200, 0.04);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.25s;
}
.user-chip:hover { border-color: rgba(227, 188, 92, 0.35); }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #1a1205;
  background: linear-gradient(135deg, var(--gold-light), var(--gold) 50%, var(--bronze));
  box-shadow: 0 4px 14px -4px rgba(227, 188, 92, 0.6);
  flex-shrink: 0;
}
.avatar.lg { width: 46px; height: 46px; border-radius: 14px; font-size: 1rem; }
.user-chip .who strong { display: block; font-size: 0.8rem; font-weight: 800; line-height: 1.3; }
.user-chip .who span { font-size: 0.68rem; color: var(--gold); font-weight: 700; }

.content { padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 26px; max-width: 1480px; width: 100%; margin-inline: auto; }

/* Page hero */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 28px 30px;
  background:
    radial-gradient(ellipse 60% 120% at 0% 0%, rgba(227, 188, 92, 0.2), transparent 60%),
    linear-gradient(135deg, rgba(36, 28, 18, 0.85), rgba(14, 11, 8, 0.9));
  border: 1px solid rgba(227, 188, 92, 0.18);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.hero::after {
  content: '';
  position: absolute;
  left: -60px;
  top: -60px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  border: 1px solid rgba(227, 188, 92, 0.12);
  box-shadow: 0 0 0 40px rgba(227, 188, 92, 0.025), 0 0 0 80px rgba(227, 188, 92, 0.015);
  pointer-events: none;
}
.hero-text { position: relative; z-index: 1; }
.hero-text .eyebrow { font-size: 0.74rem; font-weight: 800; color: var(--gold); display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hero-text h2 { font-size: clamp(1.25rem, 2.6vw, 1.7rem); font-weight: 800; line-height: 1.35; }
.hero-text p { color: var(--text-2); font-size: 0.86rem; margin-top: 4px; max-width: 640px; }
.hero-actions { position: relative; z-index: 1; display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================== Panels & Cards ============================== */
.panel {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(130%);
  -webkit-backdrop-filter: blur(20px) saturate(130%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.panel-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.panel-title h3 { font-size: 1rem; font-weight: 800; }
.panel-title p { font-size: 0.76rem; color: var(--text-3); margin-top: 1px; }
.panel-body { padding: 20px 22px; }
.panel-body.flush { padding: 0; }

.tile-ico {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--gold);
  background: linear-gradient(135deg, rgba(227, 188, 92, 0.18), rgba(227, 188, 92, 0.04));
  border: 1px solid rgba(227, 188, 92, 0.22);
}
.tile-ico .ico { width: 20px; height: 20px; }
.tile-ico.ok { color: var(--ok); background: var(--ok-bg); border-color: rgba(95, 211, 154, 0.25); }
.tile-ico.warn { color: var(--warn); background: var(--warn-bg); border-color: rgba(242, 166, 90, 0.25); }
.tile-ico.danger { color: var(--danger); background: var(--danger-bg); border-color: rgba(240, 114, 122, 0.25); }
.tile-ico.info { color: var(--info); background: var(--info-bg); border-color: rgba(143, 184, 255, 0.25); }
.tile-ico.rose { color: var(--rose); background: rgba(201, 139, 143, 0.12); border-color: rgba(201, 139, 143, 0.25); }

/* Grids */
.grid { display: grid; gap: 20px; }
.kpis { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.cols-2 { display: grid; gap: 22px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.cols-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-2.compose { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.cols-2 > *, .grid > * { min-width: 0; }

/* KPI */
.kpi {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform 0.35s var(--ease), border-color 0.35s;
}
.kpi:hover { transform: translateY(-4px); border-color: rgba(227, 188, 92, 0.3); }
.kpi::after {
  content: '';
  position: absolute;
  left: -40%;
  top: -60%;
  width: 70%;
  height: 120%;
  background: radial-gradient(circle, var(--kpi-glow, rgba(227, 188, 92, 0.16)), transparent 65%);
  pointer-events: none;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kpi-label { font-size: 0.8rem; font-weight: 700; color: var(--text-2); }
.kpi-value { font-size: 2.1rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 0.8rem; color: var(--text-3); font-weight: 700; margin-inline-start: 4px; }
.kpi-foot { margin-top: 10px; font-size: 0.72rem; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.kpi.ok { --kpi-glow: rgba(95, 211, 154, 0.14); }
.kpi.warn { --kpi-glow: rgba(242, 166, 90, 0.16); }
.kpi.danger { --kpi-glow: rgba(240, 114, 122, 0.14); }
.kpi.info { --kpi-glow: rgba(143, 184, 255, 0.14); }

/* ============================== Buttons ============================== */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 13px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: rgba(245, 230, 200, 0.05);
  color: var(--text);
  overflow: hidden;
  transition: transform 0.25s var(--spring), box-shadow 0.25s, background 0.25s, border-color 0.25s, color 0.25s, opacity 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.btn .ico { width: 17px; height: 17px; flex-shrink: 0; }
.btn:hover { transform: translateY(-2px); border-color: rgba(227, 188, 92, 0.4); background: rgba(227, 188, 92, 0.08); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.btn:disabled, .btn.is-disabled { opacity: 0.4; pointer-events: none; }
.btn.sm { padding: 7px 12px; font-size: 0.76rem; border-radius: 10px; }
.btn.sm .ico { width: 15px; height: 15px; }
.btn.lg { padding: 14px 24px; font-size: 0.92rem; border-radius: 15px; }
.btn.block { width: 100%; }

.btn-gold {
  color: #1a1205;
  border-color: rgba(255, 245, 210, 0.6);
  background: linear-gradient(180deg, #f8e2a0 0%, #e8c46a 35%, #d4a843 70%, #b88a2c 100%);
  box-shadow: 0 10px 26px -10px rgba(227, 188, 92, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.btn-gold::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  transform: skewX(-20deg);
  transition: left 0.7s var(--ease);
}
.btn-gold:hover { background: linear-gradient(180deg, #fbe9b4 0%, #edcb76 35%, #dab04d 70%, #bf9132 100%); color: #1a1205; box-shadow: 0 14px 34px -10px rgba(227, 188, 92, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.8); }
.btn-gold:hover::before { left: 130%; }

.btn-ok { color: #06251a; border-color: rgba(190, 255, 220, 0.5); background: linear-gradient(180deg, #8ae8bb, #4fc68a); box-shadow: 0 10px 24px -10px rgba(95, 211, 154, 0.7); }
.btn-ok:hover { color: #06251a; background: linear-gradient(180deg, #9ff0c9, #5bd396); border-color: rgba(190, 255, 220, 0.7); }
.btn-danger { color: var(--danger); border-color: rgba(240, 114, 122, 0.35); background: var(--danger-bg); }
.btn-danger:hover { color: #fff; background: linear-gradient(180deg, #f48a90, #d9535c); border-color: rgba(255, 190, 195, 0.5); box-shadow: 0 10px 24px -10px rgba(240, 114, 122, 0.7); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(245, 230, 200, 0.05); border-color: var(--line); color: var(--text); }

/* ============================== Forms ============================== */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 0.78rem; font-weight: 800; color: var(--text-2); }
.field .hint { font-size: 0.7rem; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 0.86rem;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: rgba(227, 188, 92, 0.6);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 4px rgba(227, 188, 92, 0.12);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.7; }
.select {
  appearance: none;
  cursor: pointer;
  padding-left: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23e3bc5c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
}
.select option { background: #15110d; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }

.search {
  position: relative;
  min-width: 220px;
  flex: 1;
  max-width: 340px;
}
.search .ico { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.search .input { padding-right: 40px; }

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s var(--ease);
}
.segmented button .ico { width: 16px; height: 16px; }
.segmented button:hover { color: var(--text); }
.segmented button.active { color: #1a1205; background: linear-gradient(180deg, #f3d98f, #d4a843); box-shadow: 0 6px 16px -6px rgba(227, 188, 92, 0.7); }
.segmented button.active.warn { color: #2a1405; background: linear-gradient(180deg, #f8c18a, #e98f3f); box-shadow: 0 6px 16px -6px rgba(242, 166, 90, 0.7); }

/* Tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding: 0 22px; overflow-x: auto; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 6px;
  margin-inline-end: 18px;
  border: 0;
  background: none;
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.25s;
}
.tab .ico { width: 17px; height: 17px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold-light); }
.tab.active::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  box-shadow: 0 0 10px var(--gold);
}
.tab .pill { font-size: 0.68rem; padding: 1px 8px; border-radius: 10px; background: rgba(245, 230, 200, 0.08); color: var(--text-2); }

/* ============================== Badges ============================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge .ico { width: 13px; height: 13px; }
.badge .pip { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: rgba(95, 211, 154, 0.28); }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: rgba(242, 166, 90, 0.3); }
.badge.warn .pip { animation: pipPulse 1.5s ease-in-out infinite; }
.badge.danger { color: var(--danger); background: var(--danger-bg); border-color: rgba(240, 114, 122, 0.3); }
.badge.info { color: var(--info); background: var(--info-bg); border-color: rgba(143, 184, 255, 0.28); }
.badge.gold { color: var(--gold-light); background: rgba(227, 188, 92, 0.12); border-color: rgba(227, 188, 92, 0.3); }
.badge.muted { color: var(--text-2); background: rgba(245, 230, 200, 0.06); border-color: var(--line); }
@keyframes pipPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 166, 90, 0.7); }
  50% { box-shadow: 0 0 0 5px rgba(242, 166, 90, 0); }
}

.code { font-family: var(--mono); font-size: 0.76rem; color: var(--gold); direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; font-weight: 800; }

/* ============================== Table ============================== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.table th {
  text-align: start;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-3);
  padding: 13px 18px;
  background: rgba(245, 230, 200, 0.025);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 14px 18px; border-bottom: 1px solid rgba(245, 230, 200, 0.05); vertical-align: middle; }
.table tbody tr { transition: background 0.2s; }
.table tbody tr:hover { background: rgba(227, 188, 92, 0.04); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .end { text-align: end; }
.table .center { text-align: center; }

.item-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.item-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--gold-light);
  background: linear-gradient(145deg, rgba(227, 188, 92, 0.16), rgba(0, 0, 0, 0.3));
  border: 1px solid rgba(227, 188, 92, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 14px -6px rgba(0, 0, 0, 0.8);
}
.item-ico .ico { width: 19px; height: 19px; }
.item-cell strong { display: block; font-weight: 800; font-size: 0.84rem; line-height: 1.45; }
.item-cell span { font-size: 0.72rem; color: var(--text-3); }

/* Stock meter */
.meter { display: flex; flex-direction: column; gap: 6px; min-width: 130px; }
.meter-row { display: flex; justify-content: space-between; font-size: 0.74rem; }
.meter-bar { height: 6px; border-radius: 6px; background: rgba(245, 230, 200, 0.08); overflow: hidden; display: flex; }
.meter-bar .avail { background: linear-gradient(90deg, #4fc68a, #8ae8bb); }
.meter-bar .resv { background: linear-gradient(90deg, #e98f3f, #f8c18a); }

/* ============================== Lists / Request cards ============================== */
.stack { display: flex; flex-direction: column; gap: 14px; }

.req-card {
  position: relative;
  border-radius: 18px;
  background: rgba(20, 16, 12, 0.6);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: border-color 0.3s, transform 0.35s var(--ease), box-shadow 0.3s;
  animation: rise 0.6s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.req-card:hover { border-color: rgba(227, 188, 92, 0.28); box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.9); }
.req-card::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 3px;
  background: var(--accent, var(--gold));
  box-shadow: 0 0 14px var(--accent, var(--gold));
}
.req-card.emergency { --accent: var(--warn); }
.req-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 20px; }
.req-meta { display: flex; align-items: center; gap: 14px; min-width: 0; }
.req-meta h4 { font-size: 0.98rem; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.req-meta p { font-size: 0.76rem; color: var(--text-3); margin-top: 3px; }
.req-meta p b { color: var(--text-2); font-weight: 700; }
.req-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.req-body { padding: 0 20px 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  font-size: 0.78rem;
}
.chip .qty { font-weight: 800; color: var(--gold-light); padding: 1px 9px; border-radius: 8px; background: rgba(227, 188, 92, 0.12); }
.note {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.78rem;
  color: var(--text-2);
  background: rgba(245, 230, 200, 0.03);
  border: 1px dashed var(--line-strong);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.note .ico { width: 16px; height: 16px; color: var(--gold); flex-shrink: 0; margin-top: 2px; }
.note.danger { color: #ffc9cc; background: var(--danger-bg); border: 1px solid rgba(240, 114, 122, 0.3); }
.note.danger .ico { color: var(--danger); }

/* Empty state */
.empty { text-align: center; padding: 46px 20px; }
.empty .tile-ico { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; }
.empty .tile-ico .ico { width: 30px; height: 30px; }
.empty h4 { font-size: 1rem; font-weight: 800; margin-bottom: 4px; }
.empty p { font-size: 0.8rem; color: var(--text-3); max-width: 380px; margin: 0 auto; }

/* ============================== Stepper ============================== */
.stepper { display: flex; align-items: flex-start; padding: 8px 0 4px; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; gap: 6px; }
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 19px;
  right: calc(50% + 24px);
  left: calc(-50% + 24px);
  height: 3px;
  border-radius: 3px;
  background: rgba(245, 230, 200, 0.1);
}
.step.done:not(:last-child)::after { background: linear-gradient(270deg, var(--ok), rgba(95, 211, 154, 0.5)); box-shadow: 0 0 10px rgba(95, 211, 154, 0.5); }
.step-node {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--text-3);
  background: #15110d;
  border: 2px solid rgba(245, 230, 200, 0.14);
  transition: all 0.5s var(--spring);
}
.step-node .ico { width: 18px; height: 18px; }
.step-label { font-size: 0.76rem; font-weight: 800; color: var(--text-3); }
.step-sub { font-size: 0.68rem; color: var(--text-3); }
.step.done .step-node { color: #06251a; background: linear-gradient(180deg, #8ae8bb, #4fc68a); border-color: rgba(190, 255, 220, 0.6); box-shadow: 0 0 18px rgba(95, 211, 154, 0.5); }
.step.done .step-label { color: var(--ok); }
.step.current .step-node { color: #2a1405; background: linear-gradient(180deg, #f8c18a, #e98f3f); border-color: rgba(255, 220, 180, 0.6); animation: nodePulse 1.8s ease-in-out infinite; }
.step.current .step-label { color: var(--warn); }
.step.rejected .step-node { color: #fff; background: linear-gradient(180deg, #f48a90, #d9535c); border-color: rgba(255, 190, 195, 0.6); box-shadow: 0 0 20px rgba(240, 114, 122, 0.6); }
.step.rejected .step-label { color: var(--danger); }
@keyframes nodePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 166, 90, 0.6); }
  50% { box-shadow: 0 0 0 9px rgba(242, 166, 90, 0); }
}

/* ============================== Catalog (engineer) ============================== */
.catalog { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.mat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(20, 16, 12, 0.55);
  border: 1px solid var(--line);
  transition: transform 0.35s var(--ease), border-color 0.3s, box-shadow 0.3s;
  animation: rise 0.55s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.mat:hover { transform: translateY(-4px); border-color: rgba(227, 188, 92, 0.32); box-shadow: 0 18px 36px -20px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(227, 188, 92, 0.08); }
.catalog.faded .mat:not(.in-cart) { opacity: 0.5; filter: grayscale(0.7); }
.catalog.faded .mat:not(.in-cart):hover { opacity: 0.8; filter: grayscale(0.3); }
.catalog.faded .mat .badge, .catalog.faded .mat .num { opacity: 0.6; }
.catalog .mat { transition: transform 0.35s var(--ease), border-color 0.3s, box-shadow 0.3s, opacity 0.4s, filter 0.4s; }
.mat.in-cart { border-color: rgba(227, 188, 92, 0.5); box-shadow: 0 0 0 1px rgba(227, 188, 92, 0.25), 0 0 24px -6px rgba(227, 188, 92, 0.35); }
.mat-top { display: flex; align-items: flex-start; gap: 12px; }
.mat-top strong { font-size: 0.84rem; font-weight: 800; line-height: 1.5; }
.mat-top .code { display: block; margin-top: 2px; font-size: 0.7rem; }
.mat-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.mat .loc { font-size: 0.7rem; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.mat .loc .ico { width: 13px; height: 13px; }
.mat .in-cart-flag {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 0.66rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 8px;
  color: #1a1205;
  background: var(--gold);
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(245, 230, 200, 0.03);
  color: var(--text-2);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
}
.filter-chip:hover { border-color: rgba(227, 188, 92, 0.35); color: var(--text); }
.filter-chip.active { color: #1a1205; background: var(--gold); border-color: var(--gold); }

/* Qty stepper */
.qty {
  display: inline-flex;
  align-items: center;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line-strong);
  overflow: hidden;
}
.qty button {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s;
}
.qty button:hover { background: rgba(227, 188, 92, 0.12); }
.qty button .ico { width: 15px; height: 15px; }
.qty input {
  width: 46px;
  height: 30px;
  border: 0;
  background: transparent;
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty input:focus { outline: none; background: rgba(227, 188, 92, 0.08); }

/* ============================== Official Document ============================== */
.doc {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(245, 230, 200, 0.06), rgba(245, 230, 200, 0.02)),
    #110e0b;
  border: 1px solid rgba(227, 188, 92, 0.22);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.doc::before {
  content: 'OPDC';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-latin);
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: rgba(227, 188, 92, 0.03);
  transform: rotate(-24deg);
  pointer-events: none;
}
.doc-head { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px double rgba(227, 188, 92, 0.35); }
.doc-head .org { font-size: 0.72rem; color: var(--text-2); line-height: 1.8; }
.doc-head .org strong { display: block; color: var(--text); font-size: 0.82rem; }
.doc-head .meta { text-align: left; font-size: 0.7rem; color: var(--text-3); line-height: 1.9; }
.doc-head .meta b { color: var(--text); }
.doc-no { font-size: 0.86rem; color: var(--gold-light); }
.doc-no-field { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--text-2); font-weight: 700; }
.doc-no-field .input { width: 130px; padding: 6px 10px; font-size: 0.8rem; font-weight: 800; border-color: rgba(227, 188, 92, 0.45); }
.doc-title { text-align: center; margin-bottom: 16px; }
.doc-title h4 { font-size: 1rem; font-weight: 800; color: var(--gold-light); }
.doc-title span { font-size: 0.72rem; color: var(--text-3); }
.doc-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; font-size: 0.76rem; padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); margin-bottom: 16px; }
.doc-info span { color: var(--text-3); }
.doc-info b { font-weight: 700; }
.doc .table th, .doc .table td { padding: 10px 10px; }
.doc-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; font-size: 0.7rem; color: var(--text-3); }
.doc-sign b { display: block; color: var(--text-2); margin-bottom: 18px; font-size: 0.72rem; }
.doc-sign .sig { font-family: var(--font-latin); color: var(--gold); font-size: 0.8rem; border-bottom: 1px dashed var(--line-strong); padding-bottom: 4px; margin: 0 8px 4px; min-height: 24px; }
.doc-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

/* ============================== Dropzone ============================== */
.dropzone {
  display: block;
  position: relative;
  border-radius: 22px;
  padding: 34px 24px;
  text-align: center;
  cursor: pointer;
  border: 2px dashed rgba(227, 188, 92, 0.3);
  background: radial-gradient(ellipse at center, rgba(227, 188, 92, 0.07), transparent 70%);
  transition: all 0.35s var(--ease);
}
.dropzone:hover, .dropzone.drag { border-color: var(--gold); background: radial-gradient(ellipse at center, rgba(227, 188, 92, 0.14), transparent 70%); }
.dropzone.drag { transform: scale(1.01); }
.dropzone .big-ico {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  color: var(--ok);
  background: linear-gradient(145deg, rgba(95, 211, 154, 0.2), rgba(95, 211, 154, 0.04));
  border: 1px solid rgba(95, 211, 154, 0.3);
  transition: transform 0.4s var(--spring);
}
.dropzone:hover .big-ico { transform: translateY(-6px) rotate(-4deg); }
.dropzone .big-ico .ico { width: 36px; height: 36px; }
.dropzone h3 { font-size: 1.08rem; font-weight: 800; margin-bottom: 4px; }
.dropzone p { font-size: 0.8rem; color: var(--text-3); max-width: 460px; margin: 0 auto 16px; }

/* ============================== Chart ============================== */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .bar { transition: opacity 0.2s; transform-origin: bottom; animation: growUp 0.9s var(--ease) both; }
.chart .bar:hover { opacity: 0.8; }
.chart text { font-family: var(--font); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.76rem; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
@keyframes growUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.rank { display: flex; flex-direction: column; gap: 14px; }
.rank-row { display: flex; flex-direction: column; gap: 6px; }
.rank-row .top { display: flex; justify-content: space-between; gap: 10px; font-size: 0.8rem; }
.rank-row .top b { font-weight: 800; }
.rank-bar { height: 8px; border-radius: 8px; background: rgba(245, 230, 200, 0.06); overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(270deg, var(--gold-light), var(--gold), var(--bronze)); animation: growX 1s var(--ease) both; transform-origin: right; }
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ============================== Timeline / Logs ============================== */
.timeline { display: flex; flex-direction: column; }
.tl-item { position: relative; display: flex; gap: 14px; padding: 12px 0; }
.tl-item:not(:last-child)::before {
  content: '';
  position: absolute;
  right: 16px;
  top: 46px;
  bottom: -6px;
  width: 1px;
  background: var(--line-strong);
}
.tl-dot { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.tl-dot .ico { width: 16px; height: 16px; }
.tl-dot.info { color: var(--info); background: var(--info-bg); }
.tl-dot.success { color: var(--ok); background: var(--ok-bg); }
.tl-dot.warning { color: var(--warn); background: var(--warn-bg); }
.tl-dot.danger { color: var(--danger); background: var(--danger-bg); }
.tl-body { flex: 1; min-width: 0; }
.tl-body p { font-size: 0.82rem; font-weight: 700; line-height: 1.6; }
.tl-body span { font-size: 0.7rem; color: var(--text-3); display: flex; gap: 10px; flex-wrap: wrap; }

/* Switch */
.switch { position: relative; width: 42px; height: 24px; display: inline-block; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 24px; background: rgba(245, 230, 200, 0.12); border: 1px solid var(--line-strong); transition: all 0.3s var(--ease); }
.switch span::before { content: ''; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: all 0.35s var(--spring); }
.switch input:checked + span { background: rgba(227, 188, 92, 0.3); border-color: rgba(227, 188, 92, 0.6); }
.switch input:checked + span::before { right: 21px; background: var(--gold-light); box-shadow: 0 0 10px var(--gold); }
.switch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ============================== Modal ============================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 2, 1, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade 0.3s ease both;
}
.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: 24px;
  background: linear-gradient(170deg, #1d1712, #0e0b08);
  border: 1px solid rgba(227, 188, 92, 0.22);
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.95);
  animation: pop 0.45s var(--spring) both;
}
.modal-card.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 1.02rem; font-weight: 800; }
.modal-head p { font-size: 0.76rem; color: var(--text-3); }
.modal-head .icon-btn { margin-inline-start: auto; width: 36px; height: 36px; }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: rgba(0, 0, 0, 0.2); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ============================== Toast ============================== */
.toasts { position: fixed; bottom: 22px; left: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 290px;
  max-width: 380px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(22, 18, 14, 0.96);
  border: 1px solid var(--line-strong);
  box-shadow: 0 20px 50px -14px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(16px);
  animation: toastIn 0.5s var(--spring) both;
  position: relative;
  overflow: hidden;
}
.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  height: 2px;
  width: 100%;
  background: var(--t-color, var(--gold));
  animation: toastTimer 3.8s linear forwards;
  transform-origin: right;
}
.toast.out { animation: toastOut 0.35s ease forwards; }
.toast .tile-ico { width: 36px; height: 36px; border-radius: 11px; }
.toast .tile-ico .ico { width: 18px; height: 18px; }
.toast strong { display: block; font-size: 0.86rem; font-weight: 800; }
.toast span { font-size: 0.76rem; color: var(--text-2); }
.toast.success { --t-color: var(--ok); }
.toast.error { --t-color: var(--danger); }
.toast.info { --t-color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-40px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-40px); } }
@keyframes toastTimer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Notifications dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  border-radius: 18px;
  background: linear-gradient(170deg, #1d1712, #0e0b08);
  border: 1px solid rgba(227, 188, 92, 0.2);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.95);
  overflow: hidden;
  animation: pop 0.35s var(--spring) both;
  z-index: 50;
}
.dropdown-head { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 800; font-size: 0.86rem; display: flex; justify-content: space-between; }
.dropdown-body { max-height: 340px; overflow-y: auto; padding: 4px 16px; }

/* ============================== Animations ============================== */
@keyframes spinAngle { to { --angle: 360deg; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.reveal { animation: rise 0.7s var(--ease) both; animation-delay: calc(var(--i, 0) * 80ms); }

/* ============================== User menu ============================== */
.user-chip { font: inherit; color: inherit; text-align: start; }
.user-menu { width: 280px; left: 0; padding: 8px; }
.user-menu-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.user-menu-head strong { display: block; font-size: 0.9rem; font-weight: 800; margin-bottom: 4px; }
.user-menu-head .badge { margin-inline-end: 6px; }
.user-menu-head .code { display: block; margin-top: 4px; font-size: 0.72rem; color: var(--text-3); }
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-radius: 11px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  text-align: start;
  transition: background 0.2s, color 0.2s;
}
.menu-item .ico { width: 17px; height: 17px; color: var(--gold); }
.menu-item:hover { background: rgba(227, 188, 92, 0.08); color: var(--text); }
.menu-item.danger, .menu-item.danger .ico { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-bg); }

/* ============================== Login ============================== */
.login { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.login-box {
  position: relative;
  width: min(460px, 100%);
  padding: 40px 34px 30px;
  border-radius: 30px;
  text-align: center;
  background: linear-gradient(170deg, rgba(34, 27, 19, 0.78), rgba(12, 10, 8, 0.92));
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  isolation: isolate;
  animation: loginIn 1s var(--ease) both;
}
.login-box::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from var(--angle), transparent 0deg, var(--gold) 70deg, var(--gold-light) 100deg, transparent 160deg, transparent 200deg, var(--rose) 260deg, var(--bronze) 300deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: spinAngle 7s linear infinite;
  pointer-events: none;
}
.login-box::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  border: 1px solid rgba(245, 230, 200, 0.08);
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(227, 188, 92, 0.16), transparent 70%);
  pointer-events: none;
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(30px) scale(0.96); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: none; }
}
.login-box .portal-logo { width: 86px; height: 86px; margin-bottom: 20px; }
.login-title {
  font-size: clamp(1.6rem, 6vw, 2.15rem);
  font-weight: 800;
  line-height: 1.35;
  background: linear-gradient(100deg, #fff 0%, #fff 40%, var(--gold-light) 50%, #fff 60%, #fff 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 6s linear infinite;
}
.login-sub { font-size: 0.8rem; color: var(--gold); font-weight: 700; margin-top: 6px; }
.login-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 24px;
  font-size: 0.84rem;
  color: var(--text-2);
}
.login-hint::before, .login-hint::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line-strong)); }
.login-hint::after { background: linear-gradient(270deg, transparent, var(--line-strong)); }
.login-form { display: flex; flex-direction: column; gap: 16px; text-align: start; }
.input-ico { position: relative; }
.input-ico > .ico { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); pointer-events: none; transition: color 0.25s; }
.input-ico .input { padding: 14px 46px 14px 14px; font-size: 0.92rem; border-radius: 14px; }
.input-ico:focus-within > .ico { color: var(--gold); }
.input-ico .ltr { direction: ltr; text-align: right; }
.input-ico .ltr::placeholder { direction: rtl; }
.pass-toggle {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.pass-toggle:hover { color: var(--gold); background: rgba(227, 188, 92, 0.08); }
.pass-toggle .ico { width: 18px; height: 18px; }
.login-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.8rem; color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--gold); cursor: pointer; }
.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffc9cc;
  background: var(--danger-bg);
  border: 1px solid rgba(240, 114, 122, 0.35);
  animation: rise 0.35s var(--ease) both;
}
.login-error .ico { color: var(--danger); width: 17px; height: 17px; }
.shake { animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.login-foot { margin-top: 22px; font-size: 0.74rem; color: var(--text-3); }
.login-credit { margin-top: 20px; text-align: center; font-size: 0.7rem; color: var(--text-3); direction: ltr; }
.login-credit b { color: var(--gold); }

.btn .spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(26, 18, 5, 0.25); border-top-color: #1a1205; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Success transition */
.welcome {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(30, 24, 16, 0.96), rgba(5, 4, 3, 0.98));
  animation: fade 0.4s ease both;
}
.welcome-check {
  width: 92px;
  height: 92px;
  margin: 0 auto 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #06251a;
  background: linear-gradient(180deg, #8ae8bb, #4fc68a);
  box-shadow: 0 0 0 10px rgba(95, 211, 154, 0.12), 0 0 60px rgba(95, 211, 154, 0.5);
  animation: pop 0.6s var(--spring) both;
}
.welcome-check .ico { width: 44px; height: 44px; stroke-width: 3; }
.welcome h2 { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; margin-bottom: 12px; animation: rise 0.6s 0.15s var(--ease) both; }
.welcome .badge { font-size: 0.86rem; padding: 7px 16px; animation: rise 0.6s 0.25s var(--ease) both; }
.welcome p { margin-top: 18px; color: var(--text-3); font-size: 0.8rem; animation: rise 0.6s 0.35s var(--ease) both; }
.welcome .bar { width: 180px; height: 3px; margin: 14px auto 0; border-radius: 3px; background: rgba(245, 230, 200, 0.1); overflow: hidden; }
.welcome .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-light), var(--gold)); animation: growX 1.3s var(--ease) both; transform-origin: right; }

.portal-logo {
  width: 92px;
  height: 92px;
  margin: 0 auto 18px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(from var(--angle), var(--gold-light), var(--rose), var(--gold), var(--bronze), var(--gold-light));
  animation: spinAngle 5s linear infinite;
  box-shadow: 0 0 40px rgba(227, 188, 92, 0.35);
}
.portal-logo img { width: 100%; height: 100%; border-radius: 50%; object-fit: contain; background: #0a0806; padding: 5px; }
@keyframes shimmer { from { background-position: 125% 0; } to { background-position: -125% 0; } }


/* ============================== Official memo (letterhead) ============================== */
.letter {
  --ink: #1b1b1b;
  --ink-2: #4a4a4a;
  position: relative;
  overflow: hidden;
  color: var(--ink);
  background: #fdfdfb;
  border-radius: 6px;
  padding: 26px 28px 0;
  font-size: 0.84rem;
  line-height: 1.85;
  box-shadow: 0 30px 70px -28px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(227, 188, 92, 0.25);
}
.letter b, .letter strong { font-weight: 800; }

.letter-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding-bottom: 14px; }
.letter-org, .letter-gov { display: flex; align-items: center; gap: 10px; }
.letter-org img { width: 52px; height: 52px; border-radius: 50%; object-fit: contain; filter: grayscale(1) contrast(1.25); }
.letter-org strong, .letter-gov strong { display: block; font-size: 0.9rem; }
.letter-org span { display: block; font-size: 0.76rem; font-weight: 700; color: var(--ink-2); line-height: 1.6; }
.letter-gov { text-align: start; }
.letter-gov .en { display: block; font-size: 0.7rem; font-weight: 700; direction: ltr; text-align: right; font-family: Arial, sans-serif; color: var(--ink-2); }
.letter-iso { width: 52px; height: 52px; flex-shrink: 0; }

.letter-ref { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 6px 0 14px; }
.ref-row { font-size: 0.8rem; color: var(--ink-2); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ref-row b { color: var(--ink); font-size: 0.86rem; }
.letter-kind { text-align: center; }
.letter-kind span { display: inline-block; padding: 4px 34px; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); font-weight: 800; }

.letter-to { font-weight: 800; font-size: 0.92rem; text-align: start; margin: 10px 0 12px; padding-inline-start: 4px; }
.letter-subject { font-weight: 800; text-align: center; text-decoration: underline; text-underline-offset: 6px; margin-bottom: 10px; }
.letter-body { text-indent: 2em; text-align: justify; margin-bottom: 14px; color: var(--ink); }

.letter-input {
  font: inherit;
  font-weight: 800;
  color: #0b3a8c;
  background: #fff8e6;
  border: 0;
  border-bottom: 1.5px dashed #b08a2c;
  border-radius: 4px 4px 0 0;
  padding: 2px 8px;
  width: 140px;
  outline: none;
  transition: background 0.2s, border-color 0.2s;
}
.letter-input:focus { background: #fff1c9; border-bottom-color: #0b3a8c; }
.letter-input::placeholder { color: #a08750; font-weight: 600; }
.ref-fields { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; }
.ref-party { display: flex; align-items: center; gap: 8px; flex: 2; min-width: 220px; }
.ref-party.ref-no { flex: 1; min-width: 160px; }
.ref-party input[type="date"] { color-scheme: dark; direction: ltr; text-align: right; }
.ref-party > span { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 800; color: var(--gold-light); white-space: nowrap; }
.ref-party .input { padding: 9px 12px; font-size: 0.82rem; }
.letter-notes { width: 100%; display: block; resize: vertical; min-height: 34px; margin: 6px 0; text-indent: 0; line-height: 1.7; }

.letter-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 0.8rem; }
.letter-table th, .letter-table td { border: 1px solid #555; padding: 6px 8px; text-align: center; }
.letter-table th { background: #ecebe6; font-weight: 800; }
.letter-table td.name { text-align: start; font-weight: 700; }
.letter-table .empty-row { color: #8a8a8a; padding: 18px; }
.letter-table .qty { background: #fff; border-color: #bdbdbd; }
.letter-table .qty button { color: #8a6a1f; }
.letter-table .qty input { color: var(--ink); }
.letter-remove { border: 0; background: none; color: #b33; cursor: pointer; padding: 4px; border-radius: 6px; display: grid; place-items: center; margin: auto; }
.letter-remove:hover { background: #fde8e8; }
.letter-remove .ico { width: 16px; height: 16px; }

.letter-regards { text-align: center; font-weight: 800; margin: 6px 0 18px; }

.letter-attach { font-size: 0.8rem; font-weight: 700; margin: -4px 0 18px; }
.letter-attach .item { padding-inline-start: 22px; font-weight: 600; color: var(--ink-2); }
.letter-signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; margin-bottom: 16px; }
.letter-signs > div { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.letter-signs b { font-size: 0.82rem; }
.letter-signs span { font-size: 0.74rem; color: var(--ink-2); font-weight: 700; }

.letter-copy { font-size: 0.76rem; color: var(--ink-2); margin-bottom: 18px; }
.letter-copy u { color: var(--ink); font-weight: 800; }

.letter-foot { margin: 0 -28px; }
.letter-doc { display: flex; align-items: center; gap: 8px; padding: 0 28px 6px; font-family: Arial, sans-serif; font-size: 0.62rem; color: var(--ink-2); direction: ltr; }
.letter-doc i { flex: 1; height: 1.5px; background: var(--ink-2); }
.letter-band { height: 18px; background: repeating-linear-gradient(-45deg, #2b2b2b 0 3px, #fdfdfb 3px 8px); border-top: 1.5px solid #2b2b2b; }

@media (max-width: 640px) {
  .letter { padding: 18px 14px 0; font-size: 0.78rem; }
  .letter-foot { margin: 0 -14px; }
  .letter-doc { padding: 0 14px 6px; }
  .letter-head { flex-direction: column; }
  .letter-gov { align-self: flex-end; }
  .letter-ref { grid-template-columns: 1fr; }
  .letter-signs { grid-template-columns: 1fr; gap: 14px; }
}

/* ============================== Utilities ============================== */
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.gap-sm { gap: 6px; }
.mt { margin-top: 14px; }
.ico { display: inline-block; vertical-align: -0.15em; flex-shrink: 0; width: 1.15em; height: 1.15em; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.text-gold { color: var(--gold); }
.sep { height: 1px; background: var(--line); margin: 4px 0; }

.overlay { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); animation: fade 0.3s both; }

/* ============================== Responsive ============================== */
@media (max-width: 1180px) {
  .cols-2, .cols-2.even, .cols-2.compose { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: none; box-shadow: -30px 0 80px rgba(0, 0, 0, 0.8); }
  .main { margin-right: 0; }
  .menu-toggle { display: grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px 40px; }
  .user-chip .who { display: none; }
  .user-chip { padding: 5px; }
}

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .login-box { padding: 32px 20px 24px; }
  .topbar-title h1 { font-size: 1.05rem; }
  .crumbs { display: none; }
  .hero { padding: 22px 20px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .doc { padding: 16px; }
  .doc-head { flex-direction: column; }
  .doc-head .meta { text-align: start; }
  .doc-info { grid-template-columns: minmax(0, 1fr); }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 16px; }
  .kpi-foot { display: none; }
  .kpi-value { font-size: 1.7rem; }
  .step-sub { display: none; }
  .search { max-width: none; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ============================== Print ============================== */
#print-root { display: none; }

@media print {
  /* margin 0 leaves the browser no room for its own URL / date / page-number lines */
  @page { size: A4; margin: 0; }
  body.print-mode #print-root { padding: 12mm 14mm 0; }
  body.print-mode { background: #fff !important; color: #000; }
  body.print-mode > *:not(#print-root) { display: none !important; }
  body.print-mode #print-root { display: block; }
  #print-root, #print-root * { color: #000 !important; background: transparent !important; box-shadow: none !important; text-shadow: none !important; -webkit-text-fill-color: #000 !important; }
  #print-root .doc { border: 1.5px solid #000; border-radius: 0; padding: 18px; }
  #print-root .doc::before { display: none; }
  #print-root .table th, #print-root .table td { border: 1px solid #555; padding: 7px 9px; }
  #print-root .badge { border: 1px solid #555; }
  #print-root .ico { display: none; }
  #print-root h2 { font-size: 16pt; margin-bottom: 4px; }
  #print-root .print-meta { font-size: 9pt; margin-bottom: 12px; }
  #print-root .letter { box-shadow: none !important; border-radius: 0; padding: 0; font-size: 10.5pt; min-height: calc(297mm - 12mm); display: flex; flex-direction: column; overflow: visible; }
  #print-root .letter-foot { margin: auto -14mm 0; padding-top: 24px; break-inside: avoid; }
  #print-root .letter-doc { padding: 0 14mm 6px !important; }
  #print-root .letter-doc { padding: 0 0 6px; }
  #print-root .letter-doc i { background: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root .letter-org img { display: block; }
  #print-root .letter-band { background: repeating-linear-gradient(-45deg, #000 0 3px, #fff 3px 8px) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root .letter-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root .letter-table th, #print-root .letter-table td { border: 1px solid #000; }
  #print-root .no-print { display: none; }
}
