:root {
  --bg: #ffffff;
  --surface: #f2f2f3;
  --text: #1f2120;
  --text-muted: #6b6c6c;
  --border: #e0e0e0;
  --accent: #33ffc9;
  --success: #02cf99;
  --error: #e92727;
  --warning: #ffd748;
  --info: #1890ff;
  --link: #607dff;
  --btn-bg: #1f2120;
  --btn-bg-hover: #363636;
  --btn-fg: #ffffff;
  --r-sm: 2px;
  --r-md: 4px;
  --error-tint-bg: #fdeaea;
  --success-tint-bg: #e6fbf4;
  --success-tint-fg: #027a5c;
  --warning-fg: #b8860b;
}

:root[data-theme="dark"] {
  --bg: #1c1e1d;
  --surface: #292b2a;
  --text: #f2f2f3;
  --text-muted: #9a9c98;
  --border: #3a3c3a;
  --btn-bg: #33ffc9;
  --btn-bg-hover: #5cffd4;
  --btn-fg: #1c1e1d;
  --error-tint-bg: #3a2020;
  --success-tint-bg: #16302a;
  --success-tint-fg: #4dffce;
  --warning-fg: #ffd748;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1e1d;
    --surface: #292b2a;
    --text: #f2f2f3;
    --text-muted: #9a9c98;
    --border: #3a3c3a;
    --btn-bg: #33ffc9;
    --btn-bg-hover: #5cffd4;
    --btn-fg: #1c1e1d;
    --error-tint-bg: #3a2020;
    --success-tint-bg: #16302a;
    --success-tint-fg: #4dffce;
  }
}

* { box-sizing: border-box; }

body {
  font-family: "MADE Outer Sans", Inter, "Space Grotesk", system-ui, sans-serif;
  font-weight: 300;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 2rem;
  position: sticky;
  top: 0;
  z-index: 10;
  overflow-x: auto;
  white-space: nowrap;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-right: 0.25rem;
  flex-shrink: 0;
}
.nav-logo { height: 22px; width: auto; display: block; }
.nav-logo-dark { display: none; }
:root[data-theme="dark"] .nav-logo-light { display: none; }
:root[data-theme="dark"] .nav-logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nav-logo-light { display: none; }
  :root:not([data-theme="light"]) .nav-logo-dark { display: block; }
}
.nav-brand-divider { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }
.nav-brand-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  letter-spacing: -0.005em;
  flex-shrink: 0;
}
nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.1rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); border-bottom-color: var(--accent); }
nav #me {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  background: var(--surface);
  border-radius: var(--r-sm);
  flex-shrink: 0;
}
.theme-toggle-btn {
  margin: 0; padding: 0.35rem 0.55rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.95rem; line-height: 1;
  cursor: pointer; flex-shrink: 0;
}
.theme-toggle-btn:hover { background: var(--border); }
nav .lang-switch { order: 1; margin-left: auto; flex-shrink: 0; }
nav .theme-toggle-btn { order: 2; }
nav #me { order: 3; margin-left: 0; }
nav #logout-link {
  order: 4;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text) !important;
  font-weight: 500;
}
nav #logout-link:hover { background: var(--surface); border-color: var(--text-muted); }

/* Hero banner (dashboard) */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2.75rem 2.5rem;
  margin-top: 1.75rem;
}
.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}
.hero-eyebrow::before {
  content: "";
  display: block;
  width: 18px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}
.hero-title {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0 0 0.9rem;
  max-width: 20ch;
  position: relative;
  z-index: 1;
}
.hero-sub {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
  max-width: 46ch;
  margin: 0;
  position: relative;
  z-index: 1;
}
.hero-stripes {
  position: absolute;
  right: 2rem;
  bottom: 1.6rem;
  display: flex;
  gap: 6px;
  opacity: 0.9;
}
.hero-stripes span {
  display: block;
  width: 8px;
  height: 34px;
  background: var(--accent);
  transform: skewX(-18deg);
}
@media (max-width: 720px) { .hero-stripes { display: none; } }

/* Page container */
body > h1,
body > .hero,
body > .error,
body > form,
body > #result,
body > label,
body > select,
body > table,
body > section,
body > .form-card,
body > .stat-tiles,
body > p {
  display: block;
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 2rem;
  padding-right: 2rem;
}
body > h1 { margin-top: 2rem; margin-bottom: 1.5rem; }

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1rem;
  font-weight: 700;
  border-left: 3px solid var(--accent);
  padding-left: 0.7rem;
  padding-bottom: 0;
  margin: 0 0 1rem;
}
section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

/* Card-style form (create page) */
.form-card {
  max-width: 480px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 1.75rem;
  margin-top: 0.5rem;
}
.form-card-sub { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 1.25rem; line-height: 1.5; }

/* Dashboard summary stat tiles */
body > .stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.9rem;
  margin-top: 1.25rem;
}
.stat-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.1rem 1.2rem;
}
.stat-tile-value { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.01em; }
.stat-tile-label { color: var(--text-muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.25rem; }
.stat-tile-accent .stat-tile-value { color: var(--info); }
.stat-tile-success .stat-tile-value { color: var(--success); }
.stat-tile-warning .stat-tile-value { color: var(--warning-fg); }
.stat-tile-error .stat-tile-value { color: var(--error); }

/* Approval stepper */
.approval-stepper {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.stepper-item { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 100px; }
.stepper-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
  background: var(--surface); color: var(--text-muted); border: 2px solid var(--border);
}
.stepper-approved .stepper-dot { background: var(--success); color: #fff; border-color: var(--success); }
.stepper-rejected .stepper-dot { background: var(--error); color: #fff; border-color: var(--error); }
.stepper-pending .stepper-dot { background: var(--bg); color: var(--text); border-color: var(--accent); }
.stepper-label { margin-top: 0.5rem; font-size: 0.76rem; text-align: center; color: var(--text-muted); line-height: 1.3; }
.stepper-approved .stepper-label, .stepper-pending .stepper-label { color: var(--text); font-weight: 500; }
.stepper-line { flex: 1; height: 2px; background: var(--border); margin-top: 15px; min-width: 20px; }
.stepper-line-done { background: var(--success); }

/* Login page: split layout (dark pitch panel + centered card) */
body.login-body { margin: 0; }
.login-shell {
  display: flex;
  min-height: 100vh;
}
.login-aside {
  display: none;
  position: relative;
  flex-shrink: 0;
  width: 420px;
  background: #1f2120;
  overflow: hidden;
  border-top: 3px solid var(--accent);
}
@media (min-width: 1024px) {
  .login-aside { display: flex; flex-direction: column; }
}
.login-aside-grid {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  background-image: linear-gradient(var(--accent) 1px, transparent 1px), linear-gradient(90deg, var(--accent) 1px, transparent 1px);
  background-size: 44px 44px;
}
.login-aside-content {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2.75rem 2.5rem;
}
.login-brand { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 3.5rem; }
.login-brand-logo { height: 20px; width: auto; flex-shrink: 0; display: block; }
.login-brand-divider { width: 1px; height: 16px; background: #3a3c3a; flex-shrink: 0; }
.login-brand-name { color: #fff; font-size: 0.88rem; font-weight: 700; margin: 0; }
.login-brand-sub { color: #6b6c6c; font-size: 0.72rem; margin: 0.15rem 0 0; }
.login-pitch h1 {
  color: #fff; font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.2; margin: 0 0 0.9rem;
}
.login-pitch h1 span { color: var(--accent); }
.login-pitch > p { color: #9a9c98; font-size: 0.84rem; line-height: 1.6; margin: 0 0 2.25rem; max-width: 30ch; }
.login-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.login-features li { display: flex; align-items: center; gap: 0.75rem; }
.login-features span:last-child { color: #9a9c98; font-size: 0.82rem; }
.login-feature-icon {
  width: 30px; height: 30px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(51, 255, 201, 0.08); border: 1px solid rgba(51, 255, 201, 0.16);
  border-radius: var(--r-md); color: var(--accent);
}

.login-main {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: 2rem;
}
.login-top-controls {
  position: absolute; top: 1.5rem; right: 1.5rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.login-theme-toggle { position: static; }
.lang-switch { display: flex; gap: 0.35rem; }
.lang-link {
  font-size: 0.76rem; font-weight: 500; text-decoration: none; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0.3rem 0.5rem;
  background: var(--bg); cursor: pointer;
}
.lang-link:hover { background: var(--surface); }
.lang-link.active { color: var(--text); border-color: var(--text); background: var(--surface); }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 2rem;
}
.login-card-logo { margin-bottom: 1.5rem; }
.login-card-logo .nav-logo { height: 20px; }
.login-card h1 { font-size: 1.4rem; margin: 0 0 0.35rem; }
.login-card-sub { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 1.5rem; }
.login-password-field { position: relative; }
.login-password-field input { padding-right: 2.5rem; }
.login-eye-toggle {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  margin: 0; padding: 0.3rem; background: transparent; color: var(--text-muted);
  border: none; cursor: pointer; display: flex;
}
.login-eye-toggle:hover { color: var(--text); background: transparent; }
#login-submit { width: 100%; }
.login-sso-divider { text-align: center; color: var(--text-muted); font-size: 0.78rem; margin: 1rem 0 0.5rem; }
.login-sso-btn {
  display: block; width: 100%; box-sizing: border-box; text-align: center;
  padding: 0.6rem 1.1rem; border-radius: var(--r-sm); font-size: 0.88rem; font-weight: 500;
  background: transparent; color: var(--text); border: 1px solid var(--border);
  text-decoration: none; transition: background 0.15s ease;
}
.login-sso-btn:hover { background: var(--btn-bg-hover); }

/* Forms */
label {
  display: block;
  margin-top: 1rem;
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
label:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  box-sizing: border-box;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.92rem;
  font-family: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--surface);
}
input[type="file"] {
  padding: 0.4rem;
  border-style: dashed;
}

/* Buttons */
button {
  margin-top: 1.25rem;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover { background: var(--btn-bg-hover); }
button:active { transform: translateY(1px); }
.button-link {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.6rem 1.1rem;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}
.button-link:hover { background: var(--btn-bg-hover); }
td button, td select, td input { margin-top: 0; }
td button { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
td button[onclick^="decideApproval('reject')"] { background: var(--error); }
td button[onclick^="decideApproval('reject')"]:hover { background: #b81f1f; }
#approval-action button[onclick*="reject"] { background: var(--error); }
#approval-action button[onclick*="reject"]:hover { background: #b81f1f; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
}
body > table {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-top: 1rem;
  border-spacing: 0;
}
section table { margin-top: 0; }
thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
th, td {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface); }
table a { color: var(--link); text-decoration: none; font-weight: 500; }
table a:hover { text-decoration: underline; }
td code {
  background: var(--surface);
  padding: 0.15rem 0.4rem;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
}

/* Status badges (solid fills, per ALVA semantic palette) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: var(--r-sm);
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
  text-transform: capitalize;
}
.badge-approved, .badge-checked_ok, .badge-completed { background: var(--success); color: #fff; }
.badge-rejected, .badge-checked_reject, .badge-blocked, .badge-voided { background: var(--error); color: #fff; }
.badge-pending, .badge-pending_documents, .badge-submitted { background: var(--warning); color: var(--text); }
.badge-in_approval, .badge-checking, .badge-awaiting_documents { background: var(--info); color: #fff; }
.badge-not_submitted { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }

/* Alerts */
.error {
  background: var(--error-tint-bg);
  color: var(--error);
  padding: 0.85rem 1rem;
  border-radius: var(--r-sm);
  border-left: 3px solid var(--error);
  margin: 1rem 0;
  font-size: 0.9rem;
  font-weight: 500;
}
#result {
  background: var(--success-tint-bg);
  color: var(--success-tint-fg);
  border-left: 3px solid var(--success);
  padding: 1rem 1.1rem;
  border-radius: var(--r-sm);
  margin: 1rem 0;
  font-size: 0.9rem;
}
#result strong { display: block; margin-bottom: 0.4rem; font-size: 0.95rem; color: var(--text); }
#d-public-link { font-family: ui-monospace, monospace; font-size: 0.82rem; cursor: pointer; }

#event-checkboxes {
  display: flex;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  font-weight: 400;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  margin: 0.3rem 1.2rem 0.3rem 0;
  color: var(--text);
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  border-width: 1px;
  flex: none;
}
