:root {
  --ink: #0e1116;
  --ink-soft: #5b6573;
  --paper: #eef1f5;
  --surface: #ffffff;
  --line: #d7dde6;
  --yellow: #ffd100;
  --yellow-ink: #1a1500;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --sidebar: #10141b;
  --sidebar-text: #c9d0db;
  --accent: #2f3a4a;
  --focus: #2563eb;
  --shadow: 0 10px 30px rgba(16, 20, 27, .06);
  --radius: 12px;
  --sans: "Manrope", "Segoe UI", sans-serif;
  --display: "Syne", "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .7rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; background: #f7f8fa; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.1rem .85rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1c2430;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .55rem .65rem 1.15rem;
  border-bottom: 1px solid #232b38;
  margin-bottom: .85rem;
}
.nikon-word {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: .02em;
  color: var(--yellow);
  line-height: 1;
}
.brand-sub {
  font-size: .78rem;
  color: #8b95a5;
  letter-spacing: .04em;
}
.brand-mark {
  width: 1.35rem;
  height: 1.35rem;
  background: var(--yellow);
  border-radius: 2px;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.brand-name {
  font-family: var(--display);
  font-size: 1.2rem;
  color: #fff;
  font-weight: 700;
}
.nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .62rem .7rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .94rem;
  font-weight: 500;
}
.nav a:hover { background: #1a212c; text-decoration: none; color: #fff; }
.nav a.active {
  background: rgba(255, 209, 0, .12);
  color: var(--yellow);
  box-shadow: inset 3px 0 0 var(--yellow);
}
.nav-icon { width: 1.15rem; height: 1.15rem; display: grid; place-items: center; flex: 0 0 auto; }
.nav-icon svg { width: 1.15rem; height: 1.15rem; }

.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid #232b38; }
.user-pill {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .65rem;
  align-items: center;
  padding: .55rem .45rem;
}
.avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  background: linear-gradient(145deg, #ff8a3d, #e4572e);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .75rem;
  font-weight: 700;
}
.user-meta { min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.user-meta strong { color: #fff; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-tag {
  color: var(--yellow);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
}
.logout-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #9aa3b2;
  text-decoration: none;
}
.logout-icon:hover { background: #1a212c; color: #fff; text-decoration: none; }
.logout-icon svg { width: 1.1rem; height: 1.1rem; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: transparent;
  color: var(--ink);
  padding: .85rem 1.4rem .15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.topbar-title { font-size: .92rem; color: var(--ink-soft); font-weight: 600; }
.topbar-user { font-size: .85rem; color: var(--ink-soft); }
.content { padding: .6rem 1.4rem 2.4rem; max-width: 1120px; width: 100%; }

.page-title {
  font-family: var(--display);
  font-size: clamp(1.7rem, 2.4vw, 2.15rem);
  margin: 0;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #152033;
}
.portal-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.portal-kicker {
  margin: 0 0 .25rem;
  color: var(--ink-soft);
  font-size: .8rem;
  font-weight: 600;
}
.portal-lead {
  margin: .35rem 0 0;
  color: var(--ink-soft);
  max-width: 42rem;
}
.loan-chip, .hero-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.loan-chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .45rem .85rem;
  box-shadow: var(--shadow);
}
.loan-chip span { color: var(--ink-soft); font-size: .78rem; margin-right: .35rem; }

.panel, .card {
  background: var(--surface);
  border: 1px solid rgba(215, 221, 230, .95);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.panel-nested {
  background: #fbfcfd;
  box-shadow: none;
}
.panel-head { margin-bottom: .9rem; }
.panel-head h2, .panel h2 {
  margin: 0 0 .2rem;
  font-family: var(--display);
  font-size: 1.15rem;
}
.panel-head p { margin: 0; color: var(--ink-soft); font-size: .9rem; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .85rem; }
.stat .label { font-size: .78rem; color: var(--ink-soft); }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  padding: .55rem .95rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink); }
.btn-yellow, .btn-accent { background: var(--yellow); color: var(--yellow-ink); border-color: #e0b800; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: #eef1f5; color: var(--ink); }
.btn-sm { padding: .32rem .6rem; font-size: .82rem; }
.btn-add { margin-top: .35rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .75rem 0; }

label { display: block; font-size: .82rem; margin-bottom: .28rem; color: #3d4756; font-weight: 600; }
input, select, textarea {
  width: 100%;
  max-width: 420px;
  padding: .58rem .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #f7f8fa;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(37, 99, 235, .28);
  border-color: #93b4f5;
  background: #fff;
}
input:disabled, select:disabled, textarea:disabled, input[readonly] {
  color: #667084;
  background: #eef1f5;
  cursor: not-allowed;
}
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: .85rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; max-width: 900px; }
.field-row input, .field-row select, .field-row textarea,
.raise-grid input, .raise-grid select, .raise-grid textarea { max-width: none; }
.raise-grid { max-width: none; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field-grow { grid-column: 1 / -1; }
.char-count { font-size: .75rem; color: var(--ink-soft); text-align: right; margin-top: .25rem; }
.char-count.is-over { color: var(--danger); font-weight: 700; }

.flash { padding: .75rem .9rem; border-radius: 8px; margin-bottom: .85rem; border: 1px solid; }
.flash-ok { background: #ecfdf3; border-color: #abefc6; color: var(--ok); }
.flash-error { background: #fef3f2; border-color: #fecdca; color: var(--danger); }
.flash-info { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }

.badge {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: #eef2f6;
  color: var(--ink-soft);
  text-transform: capitalize;
}
.badge-ok { background: #dcfae6; color: var(--ok); }
.badge-warn { background: #fef0c7; color: var(--warn); }
.badge-danger { background: #fee4e2; color: var(--danger); }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at top left, rgba(255,209,0,.18), transparent 28%),
    linear-gradient(180deg, #10141b 0 88px, transparent 88px),
    var(--paper);
}
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  font-family: var(--display);
  font-size: 1.7rem;
  margin: 0 0 .25rem;
}
.auth-card .sub { color: var(--ink-soft); margin-bottom: 1rem; font-size: .92rem; }
.muted { color: var(--ink-soft); font-size: .88rem; }
.table-wrap { overflow: auto; }
.line-items { max-width: 100%; }
.line-items input { max-width: none; }
.menu-toggle {
  display: none;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: .35rem .6rem;
  border-radius: 8px;
}

/* Requester portal specifics */
.portal-requester .content { max-width: 1080px; }
.raise-form .panel { animation: rise .35s ease both; }
.raise-form .panel:nth-child(2) { animation-delay: .04s; }
.raise-form .panel:nth-child(3) { animation-delay: .08s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .raise-form .panel { animation: none; }
}

.gear-line-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .55rem;
}
.gear-line-top h3 { margin: 0; font-size: 1rem; font-family: var(--display); }
.line-status { margin: -.2rem 0 .7rem; font-size: .86rem; }
.avail-hint {
  display: inline-block;
  margin-top: .35rem !important;
  padding: .35rem .6rem;
  border-radius: 999px;
  background: #eef8ff;
  color: #175cd3;
  font-size: .8rem !important;
}
.check-line {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.check-line input { width: auto; max-width: none; margin-top: .2rem; }
.check-line a { color: #2563eb; text-decoration: underline; }
.panel-terms { background: #fffdf3; border-color: #f0e2a0; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding: .85rem 0;
  background: linear-gradient(180deg, transparent, var(--paper) 28%);
  z-index: 5;
}

.filter-bar {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, minmax(120px, .8fr)) auto;
  gap: .75rem;
  align-items: end;
}
.filter-actions { display: flex; gap: .45rem; padding-bottom: .85rem; }
.status-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 1rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .38rem .7rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: .84rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-soft);
}
.chip span {
  background: #eef1f5;
  border-radius: 999px;
  padding: .05rem .4rem;
  font-size: .75rem;
}
.chip.is-active {
  background: #10141b;
  border-color: #10141b;
  color: var(--yellow);
}
.chip.is-active span { background: rgba(255,209,0,.18); color: var(--yellow); }
.chip:hover { text-decoration: none; }

.data-table th { white-space: nowrap; }
.loan-link { font-weight: 700; color: #1d4ed8; }
.row-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.icon-btn {
  display: inline-flex;
  padding: .28rem .55rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
}
.icon-btn:hover { background: #f3f5f8; text-decoration: none; }
.icon-download { color: #067647; border-color: #abefc6; background: #ecfdf3; }

.empty-state {
  text-align: center;
  padding: 2.4rem 1rem;
}
.empty-state h2 { font-family: var(--display); margin: 0 0 .4rem; }
.empty-state p { color: var(--ink-soft); margin: 0 0 1rem; }

.status-rail {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .45rem;
  padding: 0;
  margin: 0 0 1rem;
}
.status-rail li {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .45rem .7rem;
  text-align: center;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: capitalize;
}
.status-rail li.is-done {
  background: #10141b;
  border-color: #10141b;
  color: var(--yellow);
}
.status-rail li.is-danger { background: #fee4e2; border-color: #fecdca; color: var(--danger); }
.status-rail.is-cancelled { grid-template-columns: repeat(5, 1fr); }

.profile-panel { max-width: 760px; }
.password-toggle { margin: .4rem 0 1rem; }
.btn-accent { background: #3b4660; border-color: #3b4660; color: #fff; }
.portal-requester .btn-accent { background: #44506a; }

.print-sheet .print-brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .8rem;
}
.policy-doc ul { padding-left: 1.1rem; }
.policy-doc li { margin-bottom: .45rem; }

@media (max-width: 980px) {
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .status-rail, .status-rail.is-cancelled { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    transform: translateX(-105%);
    z-index: 30;
    transition: transform .2s;
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-block; }
  .content { padding: 1rem; }
  .topbar { padding: .75rem 1rem 0; }
}
@media print {
  .sidebar, .topbar, .actions, .flash, .no-print, .sticky-actions, .filter-bar, .status-chips { display: none !important; }
  .app-shell { display: block; }
  .content { max-width: none; padding: 0; }
  .panel { box-shadow: none; border: none; }
}
