:root {
  --ink: #17324d;
  --muted: #6d7f90;
  --line: #dfe7ed;
  --surface: #ffffff;
  --canvas: #f4f7f9;
  --brand: #0f766e;
  --brand-dark: #0b5d57;
  --brand-soft: #e7f5f2;
  --orange: #d97706;
  --danger: #c2413d;
  --shadow: 0 10px 28px rgba(25, 55, 78, .08);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #e6f5f2 0 18%, transparent 45%), var(--canvas); }
.login-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 36px; }
.brand-mark { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-logo { width: 44px; height: 44px; display: grid; place-items: center; color: #fff; background: var(--brand); font-size: 21px; font-weight: 800; border-radius: 8px; }
.brand-mark strong { display: block; font-size: 20px; letter-spacing: .02em; }
.brand-mark small { color: var(--muted); }
.login-card h1 { margin: 0 0 8px; font-size: 27px; }
.login-card p { color: var(--muted); line-height: 1.7; margin: 0 0 22px; }
.role-grid { display: grid; gap: 10px; }
.auth-form { display: grid; gap: 14px; margin-top: 18px; }
.link-button { border: 0; background: transparent; color: var(--brand-dark); padding: 10px 0 0; text-align: left; font-size: 13px; }
.link-button:hover { text-decoration: underline; }
.role-choice { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border: 1px solid var(--line); background: #fff; text-align: left; color: var(--ink); }
.role-choice:hover { border-color: var(--brand); background: var(--brand-soft); }
.role-choice strong { display: block; }
.role-choice small { color: var(--muted); }
.demo-note { margin-top: 20px !important; font-size: 12px; border-top: 1px solid var(--line); padding-top: 16px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; min-height: 100vh; padding: 24px 16px; background: #12354c; color: #dcebf2; }
.sidebar .brand-mark { margin: 0 8px 34px; }
.sidebar .brand-logo { background: #2bb5a5; }
.sidebar .brand-mark strong { color: #fff; font-size: 17px; }
.sidebar .brand-mark small { color: #a6c1cc; }
.side-label { margin: 0 10px 8px; color: #8db1bf; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.nav-stack { display: grid; gap: 4px; }
.nav-item { border: 0; color: #c8dde5; background: transparent; padding: 11px 12px; display: flex; align-items: center; gap: 10px; text-align: left; border-radius: 6px; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-icon { width: 22px; color: #89cfc7; text-align: center; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.14); padding-top: 16px; }
.user-mini { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #d8f1ed; color: var(--brand-dark); font-weight: 800; }
.user-mini strong { display: block; font-size: 13px; color: #fff; }
.user-mini small { color: #9fbcc6; }
.ghost-dark { width: 100%; padding: 9px 10px; border: 1px solid rgba(255,255,255,.2); background: transparent; color: #dcebf2; border-radius: 5px; }

.main { min-width: 0; }
.topbar { min-height: 68px; display: flex; justify-content: space-between; align-items: center; padding: 14px 30px; background: #fff; border-bottom: 1px solid var(--line); }
.crumb { color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.sandbox-badge, .pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; color: #126d64; background: var(--brand-soft); font-size: 12px; }
.role-switch { padding: 8px 10px; border: 1px solid var(--line); color: var(--ink); background: #fff; border-radius: 5px; }
.content { width: min(1260px, 100%); padding: 28px 30px 52px; margin: 0 auto; }
.page-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 22px; }
.page-heading h1 { margin: 0 0 6px; font-size: clamp(24px, 3vw, 32px); }
.page-heading p { margin: 0; color: var(--muted); }
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.button { border: 1px solid transparent; border-radius: 5px; padding: 10px 14px; font-weight: 650; }
.button.primary { background: var(--brand); color: white; }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { background: white; border-color: var(--line); color: var(--ink); }
.button.secondary:hover { border-color: var(--brand); color: var(--brand-dark); }
.button.danger { background: #fff5f4; border-color: #f1c9c7; color: var(--danger); }
.button.small { padding: 7px 10px; font-size: 12px; }
.button:disabled { opacity: .45; cursor: not-allowed; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 18px; background: #fff; border: 1px solid var(--line); }
.metric label { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 10px; font-size: 25px; }
.metric small { display: block; margin-top: 5px; color: var(--muted); }
.metric.brand { background: var(--brand); color: #fff; border-color: var(--brand); }
.metric.brand label, .metric.brand small { color: #c8f0eb; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 18px; }
.panel { background: #fff; border: 1px solid var(--line); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head small { color: var(--muted); }
.panel-body { padding: 18px; }
.detail-applications { margin-top: 10px; }
.admin-audit-panel { margin-top: 18px; }
.inline-spacer { height: 12px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: 7px; color: var(--ink); }
.notice { padding: 13px 14px; background: #fff9e8; border: 1px solid #f1df9d; color: #805c0c; line-height: 1.6; font-size: 13px; }
.notice.info { background: var(--brand-soft); border-color: #bce5df; color: #126d64; }

.task-list { display: grid; gap: 10px; }
.task-row { padding: 14px; border: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.task-row:hover { border-color: #99cfc8; }
.task-main h3 { margin: 0 0 6px; font-size: 15px; }
.task-meta { color: var(--muted); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.task-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.status.active { color: #126d64; background: #e1f5f1; }
.status.pending_review { color: #8a5a06; background: #fff2cc; }
.status.paused, .status.rejected { color: #815f17; background: #fff7df; }
.status.closed, .status.accepted { color: #5e6b76; background: #eef1f3; }
.status.submitted { color: #155da0; background: #e6f1ff; }
.status.applied { color: #7454a6; background: #f2ebff; }
.status.disputed { color: #a5302e; background: #fff0ef; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; font-weight: 700; background: #f8fafb; }
td.wrap { white-space: normal; min-width: 260px; }
tr:last-child td { border-bottom: 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #415a6d; font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #cbd8e0; border-radius: 4px; padding: 11px 12px; color: var(--ink); background: #fff; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.field textarea { min-height: 130px; resize: vertical; }
.field-help { color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 18px; }

.ledger-line { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ledger-line:last-child { border-bottom: 0; }
.ledger-line strong { display: block; font-size: 13px; }
.ledger-line small { color: var(--muted); }
.amount-positive { color: #14856e; font-weight: 700; }
.amount-negative { color: var(--danger); font-weight: 700; }
.toast-region { position: fixed; z-index: 10; right: 22px; bottom: 22px; display: grid; gap: 8px; width: min(360px, calc(100vw - 44px)); }
.toast { padding: 13px 15px; color: #fff; background: #17324d; box-shadow: var(--shadow); border-left: 4px solid #2bb5a5; font-size: 13px; }
.toast.error { border-left-color: #f1a29e; }
.mobile-nav { display: none; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 22px 16px 88px; }
  .topbar { padding: 13px 16px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); left: 0; right: 0; bottom: 0; padding: 7px 5px max(7px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
  .mobile-nav button { border: 0; background: transparent; color: var(--muted); display: grid; gap: 3px; place-items: center; font-size: 10px; }
  .mobile-nav button.active { color: var(--brand); font-weight: 700; }
  .mobile-nav span { font-size: 17px; }
}
@media (max-width: 580px) {
  .top-actions .role-switch { max-width: 112px; }
  .page-heading { display: block; }
  .heading-actions { margin-top: 14px; justify-content: flex-start; }
  .metric-grid { gap: 9px; }
  .metric { padding: 13px; }
  .metric strong { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .task-row { grid-template-columns: 1fr; }
  .task-actions { justify-content: flex-start; }
  .login-card { padding: 25px; }
}
