:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #18212b;
  --muted: #637180;
  --border: #d9e0e6;
  --accent: #08776d;
  --accent-hover: #06645c;
  --danger: #b53a3a;
  --warning-bg: #fff8e7;
  --warning-border: #e9c86a;
  --success-bg: #edf8f4;
  --success-border: #77bca9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }

button, .button-link {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 15px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover, .button-link:hover { background: var(--accent-hover); }
button:disabled { opacity: .55; cursor: not-allowed; }

button.secondary, .button-link.secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

button.secondary:hover, .button-link.secondary:hover { background: #eef2f5; }

.portal-header {
  min-height: 64px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .96);
}

.header-inner {
  width: min(1040px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { font-size: 18px; font-weight: 800; color: var(--text); }
.brand span { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-user { color: var(--muted); font-size: 14px; }

.auth-shell {
  width: min(460px, calc(100% - 32px));
  margin: 9vh auto 40px;
}

.auth-title { margin-bottom: 22px; }
.auth-title h1 { margin: 0; font-size: 26px; }
.auth-title p { margin: 7px 0 0; color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #edf1f4;
  margin-bottom: 22px;
}

.segment button { background: transparent; color: var(--muted); }
.segment button:hover { background: #e3e9ed; }
.segment button.active { background: #fff; color: var(--text); border-color: var(--border); }

.auth-form { display: none; }
.auth-form.active { display: block; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 700; }

.field input, .field textarea, .key-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #bec9d2;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.field textarea { min-height: 100px; resize: vertical; }
.field input:focus, .field textarea:focus, .key-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 119, 109, .12);
}

.form-action { width: 100%; }
.form-message { min-height: 20px; margin-top: 13px; font-size: 14px; color: var(--danger); }

.portal-main {
  width: min(1040px, calc(100% - 32px));
  margin: 32px auto 60px;
}

.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 26px; }
.page-head p { margin: 7px 0 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 18px; }
.section-title { margin: 0 0 6px; font-size: 18px; }
.section-copy { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }

.status-box {
  border: 1px solid var(--border);
  border-left: 4px solid #8a98a5;
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: #f8fafb;
}

.status-box.pending { background: var(--warning-bg); border-color: var(--warning-border); }
.status-box.approved { background: var(--success-bg); border-color: var(--success-border); }
.status-box.rejected { border-color: #d99a9a; background: #fff3f3; }
.status-label { font-weight: 800; }
.status-detail { margin-top: 5px; color: var(--muted); font-size: 14px; }

.key-box { display: flex; gap: 8px; align-items: stretch; }
.key-box input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-width: 0; }
.meta-list { display: grid; gap: 12px; margin: 0; }
.meta-row { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid #edf0f2; padding-bottom: 10px; }
.meta-row:last-child { border-bottom: 0; padding-bottom: 0; }
.meta-row dt { color: var(--muted); }
.meta-row dd { margin: 0; text-align: right; font-weight: 700; word-break: break-word; }
.hidden { display: none !important; }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .header-inner { align-items: flex-start; padding: 12px 0; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .header-user { width: 100%; text-align: right; }
  .key-box { flex-wrap: wrap; }
  .key-box input { flex: 1 1 100%; }
}
