:root {
  --ink: #172033;
  --muted: #647089;
  --line: #dfe5ee;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  --navy: #101d38;
  --navy-soft: #1b2d52;
  --blue: #315ee7;
  --blue-soft: #eaf0ff;
  --green: #17845a;
  --green-soft: #e8f7f0;
  --amber: #a76207;
  --amber-soft: #fff4dc;
  --red: #bb3d4a;
  --red-soft: #ffebee;
  --shadow: 0 18px 44px rgba(31, 49, 83, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

.login-surface {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 15% 15%, rgba(49, 94, 231, .25), transparent 34%),
    radial-gradient(circle at 85% 80%, rgba(23, 132, 90, .18), transparent 32%),
    linear-gradient(140deg, #0d1931, #172b52 60%, #0e3150);
}

.login-card {
  width: min(450px, 100%);
  padding: 38px;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 24px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 28px 90px rgba(3, 10, 28, .32);
}

.brand-mark {
  width: 58px;
  height: 58px;
  margin-bottom: 26px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: white;
  background: linear-gradient(145deg, var(--blue), #2544a9);
  font-weight: 900;
  letter-spacing: .06em;
  box-shadow: 0 12px 28px rgba(49, 94, 231, .3);
}

.login-card h1 { margin: 0; font-size: clamp(28px, 6vw, 38px); letter-spacing: -.035em; }
.login-copy { color: var(--muted); line-height: 1.6; }
.login-card form { display: grid; gap: 16px; margin: 26px 0 14px; }
label { display: grid; gap: 7px; color: #37445c; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfd7e5;
  border-radius: 11px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49, 94, 231, .12); }
textarea { min-height: 90px; resize: vertical; }

button {
  border: 0;
  border-radius: 11px;
  padding: 11px 16px;
  color: white;
  background: var(--blue);
  font-weight: 800;
}
button:hover { filter: brightness(.96); }
button:disabled { opacity: .55; cursor: wait; }
.secondary-button { color: var(--ink); background: #eef2f8; }
.form-message { min-height: 22px; color: var(--red); font-weight: 700; }
.login-card small { color: var(--muted); }

.portal-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  color: white;
  background: linear-gradient(180deg, var(--navy), #0a1429);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 28px; }
.sidebar-brand > span {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px;
  background: var(--blue); font-size: 12px; font-weight: 900;
}
.sidebar-brand div { display: grid; gap: 2px; }
.sidebar-brand small { color: #aebbd2; }
.sidebar nav { display: grid; gap: 7px; }
.nav-button { width: 100%; text-align: left; color: #c8d3e8; background: transparent; }
.nav-button:hover, .nav-button.is-active { color: white; background: var(--navy-soft); }
.nav-button.is-active { box-shadow: inset 3px 0 var(--blue); }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 13px; color: #aebbd2; font-size: 12px; }
.sidebar-footer i { width: 8px; height: 8px; border-radius: 50%; background: #43d49a; box-shadow: 0 0 0 4px rgba(67, 212, 154, .13); }

.workspace { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  padding: 20px 30px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .94);
}
.topbar h2 { margin: 0; font-size: 22px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.company-chip, .user-chip {
  min-width: 130px; display: grid; gap: 2px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: white;
}
.company-chip small, .user-chip small { color: var(--muted); font-size: 11px; }
.company-chip strong, .user-chip strong { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.content { min-width: 0; padding: 28px 30px 42px; }
.statusbar { display: flex; justify-content: space-between; padding: 12px 30px; border-top: 1px solid var(--line); color: var(--muted); background: white; font-size: 12px; }

.hero {
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  margin-bottom: 22px; padding: 26px; border-radius: 19px; color: white;
  background: linear-gradient(120deg, #172b52, #244c91 65%, #287a75); box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 8px; font-size: clamp(25px, 4vw, 35px); letter-spacing: -.03em; }
.hero p:not(.eyebrow) { max-width: 680px; margin: 0; color: #dce6f7; line-height: 1.5; }
.hero .eyebrow { color: #9eb9ff; }
.hero-badge { min-width: 125px; display: grid; gap: 5px; padding: 14px 17px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 14px; background: rgba(255, 255, 255, .08); }
.hero-badge span { color: #c7d6ee; font-size: 11px; }
.hero-badge strong { font-size: 16px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; }
.metric, .panel, .profile-card {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 24px rgba(31, 49, 83, .06);
}
.metric { display: grid; gap: 7px; padding: 19px; border-top: 4px solid var(--blue); }
.metric.green { border-top-color: var(--green); }
.metric.amber { border-top-color: #dc920c; }
.metric.red { border-top-color: var(--red); }
.metric span, .metric small { color: var(--muted); }
.metric strong { font-size: 28px; letter-spacing: -.04em; }
.panel { margin-bottom: 20px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0 0 4px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }
.panel-body { padding: 20px; }

.profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.profile-card { padding: 18px; }
.profile-card small { display: block; margin-bottom: 6px; color: var(--muted); }
.profile-card strong { overflow-wrap: anywhere; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.request-grid { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 13px; }
.request-grid .wide { grid-column: 1 / -1; }
.request-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.signature-list { display: flex; flex-direction: column; gap: 12px; }
.signature-card { display: grid; gap: 13px; padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.signature-card strong,.signature-card small { display: block; }
.signature-card small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.signature-actions,.signature-decision-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.signature-consent { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 10px; background: #f4f7fb; color: #42516a; font-size: 11px; line-height: 1.5; }
.signature-consent input { width: 17px; height: 17px; margin: 0; flex: 0 0 auto; }
.primary-button { padding: 9px 13px; background: var(--red); color: #fff; font-size: 10px; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f8faff; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: #4c5970; background: #edf1f6; font-size: 10px; font-weight: 900; }
.status.success { color: var(--green); background: var(--green-soft); }
.status.warning { color: var(--amber); background: var(--amber-soft); }
.status.danger { color: var(--red); background: var(--red-soft); }
.download-button { padding: 7px 10px; font-size: 12px; }
.load-more { display: flex; justify-content: center; padding: 16px; }
.empty, .loading, .error-state, .success-state { padding: 30px; color: var(--muted); text-align: center; }
.error-state { color: var(--red); }
.success-state { color: var(--green); background: var(--green-soft); border-radius: 11px; }

@media (max-width: 1050px) {
  .portal-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 760px) {
  .portal-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 15px; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-footer { display: none; }
  .topbar { padding: 16px; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .content { padding: 18px 16px 35px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .metric-grid, .profile-grid, .filter-grid, .request-grid { grid-template-columns: 1fr; }
  .request-grid .wide { grid-column: auto; }
  .statusbar { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
}
