:root {
  --ink: #172321;
  --muted: #64716e;
  --surface: #ffffff;
  --canvas: #f3f5f1;
  --line: #dce3de;
  --primary: #0c756b;
  --primary-dark: #095e56;
  --accent: #df7b3d;
  --danger: #b83d48;
  --sidebar: #132d2a;
  --sidebar-muted: #a9bfba;
  --shadow: 0 18px 44px rgba(19, 45, 42, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
a { color: var(--primary); text-decoration: none; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .87em; overflow-wrap: anywhere; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 30px 22px; display: flex; flex-direction: column; color: white; background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; font-weight: 800; letter-spacing: -.04em; color: #12302c; background: #b9e4d9; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--sidebar-muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 7px; margin-top: 46px; }
.sidebar nav a { padding: 12px 14px; border-radius: 10px; color: var(--sidebar-muted); font-weight: 600; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(255,255,255,.1); }
.logout { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.13); color: var(--sidebar-muted); font-size: 12px; }
.logout strong { color: white; font-size: 14px; }
.content { min-width: 0; padding: 44px clamp(24px, 4vw, 64px) 70px; }

.page-header { min-height: 74px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 3vw, 40px); line-height: 1.1; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.02em; }
.eyebrow { margin-bottom: 7px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 13px; font-size: 14px; font-weight: 700; }

.button { min-height: 38px; padding: 9px 14px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 700; white-space: nowrap; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--primary); }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { color: var(--primary-dark); border-color: #aad0c8; background: #e8f4f1; }
.button.danger { color: var(--danger); border-color: #e9bbc0; background: #fff0f1; }
.button.ghost { color: inherit; border-color: var(--line); background: transparent; }
.sidebar .button.ghost { color: white; border-color: rgba(255,255,255,.2); }
.button.small { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.button.wide { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric { position: relative; min-height: 150px; padding: 23px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.metric::after { content: ""; position: absolute; right: -22px; bottom: -32px; width: 96px; height: 96px; border-radius: 50%; background: #edf2ee; }
.metric.accent { color: white; border-color: transparent; background: var(--primary); }
.metric.accent::after { background: rgba(255,255,255,.1); }
.metric span, .metric small { display: block; }
.metric span { font-size: 13px; font-weight: 700; }
.metric strong { display: block; margin: 11px 0 7px; font-size: 38px; line-height: 1; letter-spacing: -.04em; }
.metric small { color: var(--muted); }
.metric.accent small { color: #c4e1dc; }

.panel { margin-bottom: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { min-height: 70px; padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-heading .eyebrow { margin-bottom: 3px; }
.table-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 13px 17px; color: var(--muted); background: #f7f9f6; font-size: 11px; text-align: left; letter-spacing: .06em; text-transform: uppercase; }
td { padding: 15px 17px; border-top: 1px solid #e9eeea; vertical-align: middle; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.primary-link { color: var(--ink); font-weight: 800; }
.primary-link:hover { color: var(--primary); }

.filters, .split-toolbar { margin-bottom: 20px; }
.filters { padding: 16px; display: flex; align-items: end; gap: 12px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.72); }
.filters label, .create-form label, .stack label, .action-stack label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.filters input, .filters select, .create-form input, .stack input, .action-stack input { min-height: 40px; padding: 9px 11px; border: 1px solid #cfd8d2; border-radius: 8px; outline: none; color: var(--ink); background: white; }
.filters input:focus, .filters select:focus, .create-form input:focus, .stack input:focus, .action-stack input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(12,117,107,.12); }
.search-field { min-width: min(310px, 100%); flex: 1; }
.audit-filters label { min-width: 145px; }
.split-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: stretch; }
.grow { margin-bottom: 0; }
.create-form { padding: 16px; display: flex; align-items: end; gap: 10px; border: 1px solid #abd1c8; border-radius: 13px; background: #edf8f5; }
.batch-toolbar { min-height: 62px; padding: 12px 17px; display: flex; align-items: center; border-bottom: 1px solid var(--line); background: #fbfcfa; }
.batch-controls { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.batch-controls label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.batch-controls select { min-width: 150px; min-height: 36px; padding: 7px 10px; border: 1px solid #cfd8d2; border-radius: 8px; color: var(--ink); background: white; }
.batch-controls select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(12,117,107,.12); }
.batch-count { min-width: 76px; padding-bottom: 9px; color: var(--muted); font-size: 12px; }
.selection-cell { width: 42px; padding-right: 4px; text-align: center; }
.selection-cell input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.button:disabled { opacity: .48; cursor: not-allowed; transform: none; }

.status { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status.pending { color: #8a5517; background: #fff0cf; }
.status.approved { color: #086357; background: #dff4ef; }
.status.rejected { color: #a22b38; background: #fde7e9; }
.status.suspended { color: #58615f; background: #e7ebea; }
.status.large { padding: 8px 13px; font-size: 13px; }
.target-type { display: inline-flex; padding: 3px 7px; border-radius: 6px; color: #4b5c58; background: #e9efec; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.row-actions { display: flex; gap: 7px; align-items: center; }
.row-actions form { margin: 0; }

.pagination { min-height: 60px; padding: 12px 17px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pagination div { display: flex; gap: 8px; }
.empty { padding: 42px 20px; color: var(--muted); text-align: center; }
.loading { opacity: .55; pointer-events: none; }
.notice { margin-bottom: 18px; padding: 13px 15px; border: 1px solid; border-radius: 10px; font-size: 14px; }
.notice.success { color: #075e53; border-color: #aad8cf; background: #e7f7f3; }
.notice.error { color: #9b2632; border-color: #e9b5bb; background: #fff0f1; }
.notice.warning { color: #795019; border-color: #ecd19d; background: #fff7e5; }

.activity-list article { padding: 16px 22px; display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 13px; border-top: 1px solid #edf0ed; }
.activity-list article:first-child { border-top: 0; }
.activity-list p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.activity-list time { color: var(--muted); font-size: 12px; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #fbe9de; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr); gap: 22px; }
.detail-list { margin: 0; padding: 7px 22px 17px; }
.detail-list div { padding: 13px 0; display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; border-bottom: 1px solid #edf0ed; }
.detail-list div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: 13px; }
.detail-list dd { margin: 0; font-weight: 650; }
.action-stack { padding: 20px; display: grid; gap: 18px; }
.action-stack form { padding-bottom: 18px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.action-stack form:last-child { padding-bottom: 0; border-bottom: 0; }

.credential-card { margin-bottom: 20px; padding: 22px; display: grid; grid-template-columns: .65fr 1.35fr; gap: 28px; color: #f4fbf9; border-radius: 16px; background: #173b36; box-shadow: var(--shadow); }
.credential-card .eyebrow { color: #8fd8ca; }
.credential-card p { color: #b9cdc9; }
.credential-card dl { margin: 0; min-width: 0; }
.credential-card dl div { padding: 9px 0; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; border-bottom: 1px solid rgba(255,255,255,.12); }
.credential-card dl div:last-child { border-bottom: 0; }
.credential-card dt { color: #a9c1bc; font-size: 12px; }
.credential-card dd { margin: 0; min-width: 0; display: flex; align-items: flex-start; gap: 8px; }
.credential-card code { min-width: 0; flex: 1; color: white; }
.copy-button { padding: 3px 7px; border: 1px solid rgba(255,255,255,.24); border-radius: 6px; color: white; background: transparent; cursor: pointer; }

.login-page { display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #d8eee8, transparent 35%), radial-gradient(circle at 90% 80%, #f6ddcf, transparent 36%), #eef2ed; }
.login-card { width: min(440px, 100%); padding: 38px; display: grid; gap: 27px; border: 1px solid rgba(255,255,255,.9); border-radius: 22px; background: rgba(255,255,255,.9); box-shadow: 0 26px 70px rgba(16,54,48,.16); backdrop-filter: blur(14px); }
.login-brand { color: var(--ink); }
.login-brand small { color: var(--muted); }
.stack { display: grid; gap: 16px; }
.stack input { width: 100%; margin-top: 2px; }
.login-foot { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
details summary { color: var(--primary); cursor: pointer; font-weight: 700; }
pre { max-width: 460px; padding: 10px; overflow: auto; border-radius: 8px; background: #f2f5f2; font-size: 12px; }

@media (max-width: 1000px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid, .split-toolbar { grid-template-columns: 1fr; }
  .create-form { justify-content: space-between; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px; display: block; }
  .sidebar nav { margin-top: 17px; display: flex; overflow-x: auto; }
  .sidebar nav a { flex: 0 0 auto; }
  .logout { margin-top: 14px; }
  .content { padding: 28px 16px 54px; }
  .page-header { min-height: 0; display: block; }
  .page-header > .button, .page-header > .status { margin-top: 12px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { min-height: 132px; padding: 18px; }
  .metric strong { font-size: 32px; }
  .filters, .create-form { align-items: stretch; }
  .filters > *, .create-form > * { width: 100%; }
  .batch-controls { width: 100%; }
  .batch-controls label { flex: 1; }
  .batch-controls select { width: 100%; }
  .batch-count { margin-right: auto; }
  .credential-card { grid-template-columns: 1fr; }
  .credential-card dl div { grid-template-columns: 1fr; }
  .activity-list article { grid-template-columns: 12px minmax(0, 1fr); }
  .activity-list time { grid-column: 2; }
  .detail-list div { grid-template-columns: 1fr; gap: 5px; }
  .pagination { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .login-card { padding: 27px 22px; }
}

.portal-shell { min-height: 100vh; }
.portal-header { min-height: 82px; padding: 16px clamp(20px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 24px; color: white; background: var(--sidebar); }
.portal-actions { display: flex; align-items: center; gap: 24px; }
.portal-nav { display: flex; align-items: center; gap: 6px; }
.portal-nav a { padding: 9px 12px; border-radius: 8px; color: var(--sidebar-muted); font-size: 13px; font-weight: 700; }
.portal-nav a:hover, .portal-nav a.active { color: white; background: rgba(255,255,255,.1); }
.portal-header .logout { margin: 0; padding: 0; border: 0; }
.portal-content { max-width: 1320px; margin: 0 auto; }
.credential-panel { overflow: hidden; }
.credential-fields, .edit-grid, .settings-form { padding: 22px; display: grid; gap: 16px; }
.credential-fields label, .edit-grid label, .settings-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.credential-fields input, .edit-grid input, .edit-grid textarea, .settings-form input { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cfd8d2; border-radius: 8px; color: var(--ink); background: white; }
.edit-grid textarea { min-height: 110px; resize: vertical; font: inherit; }
.edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.edit-grid label:nth-child(3), .edit-grid label:nth-child(4) { grid-column: 1 / -1; }
.account-room-form label:nth-child(4) { grid-column: auto; }
.account-room-review-note { grid-column: 1 / -1; margin: 0; }
.edit-grid .checkbox-field { display: flex; align-items: center; color: var(--ink); }
.edit-grid .checkbox-field input { width: auto; min-height: auto; }
.secret-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.form-panel { max-width: 720px; }
.danger-zone form { padding: 20px; }

@media (max-width: 760px) {
  .portal-header { align-items: flex-start; flex-direction: column; }
  .portal-actions { width: 100%; align-items: stretch; flex-direction: column; gap: 12px; }
  .portal-nav { overflow-x: auto; }
  .portal-nav a { flex: 0 0 auto; }
  .portal-header .logout { width: 100%; }
  .edit-grid { grid-template-columns: 1fr; }
  .edit-grid label:nth-child(3), .edit-grid label:nth-child(4) { grid-column: auto; }
  .secret-row { grid-template-columns: 1fr 1fr; }
  .secret-row input { grid-column: 1 / -1; }
}