:root {
  --ink: #17251f;
  --muted: #718078;
  --line: #dfe7e2;
  --green: #176b4d;
  --green-dark: #0f3527;
  --green-soft: #e9f5ee;
  --amber: #b97816;
  --red: #aa4936;
  --paper: #ffffff;
  --canvas: #f3f6f4;
  --shadow: 0 18px 50px rgba(25, 57, 43, 0.08);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% -10%, rgba(48, 135, 93, 0.12), transparent 30%),
    var(--canvas);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

.site-header,
.console-header {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 max(24px, env(safe-area-inset-left));
}

.site-header {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 50%;
  width: min(760px, 100%);
  padding-right: 20px;
  padding-left: 20px;
  transform: translateX(-50%);
  color: #fff;
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand-mark {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  color: var(--green-dark);
  background: #d9f5e6;
  border-radius: 13px 13px 13px 4px;
  font-size: 17px;
  font-weight: 900;
}

.header-link {
  padding: 9px 14px;
  color: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  font-size: 13px;
}

.driver-main {
  width: min(760px, 100%);
  margin: 0 auto;
  padding-bottom: 52px;
}

.driver-hero {
  position: relative;
  min-height: 390px;
  padding: 124px clamp(24px, 7vw, 64px) 54px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 92% 2%, rgba(131, 220, 168, 0.3), transparent 34%),
    linear-gradient(145deg, #113326, #176b4d);
  border-radius: 0 0 40px 40px;
}

.driver-hero::after {
  position: absolute;
  right: -130px;
  bottom: -250px;
  width: 500px;
  height: 500px;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
}

.eyebrow {
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.driver-hero .eyebrow { color: rgba(255, 255, 255, 0.52); }

.driver-hero h1 {
  margin: 18px 0 14px;
  font-size: clamp(38px, 7vw, 58px);
  line-height: 1.13;
  letter-spacing: -1.5px;
}

.driver-hero p {
  width: min(520px, 90%);
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 16px;
  line-height: 1.8;
}

.hero-points {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.hero-points span {
  padding: 8px 13px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  font-size: 12px;
}

.notice,
.panel,
.loading-card,
.empty-card,
.info-strip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.driver-main > .notice,
.form-panel,
.success-panel,
.info-strip {
  width: calc(100% - 32px);
  margin-right: auto;
  margin-left: auto;
}

.notice {
  margin-top: 18px;
  padding: 15px 18px;
  color: #73500d;
  background: #fff8e7;
  border-color: #efdfb5;
  font-size: 14px;
  line-height: 1.65;
}

.notice.error {
  color: #993f2d;
  background: #fff3ef;
  border-color: #efc9bf;
}

.notice.success {
  color: #226a4d;
  background: #edf8f1;
  border-color: #cfe7d8;
}

.form-panel {
  margin-top: -26px;
  padding: clamp(24px, 5vw, 36px);
  box-shadow: var(--shadow);
}

.panel-heading,
.section-bar,
.page-heading {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.panel-heading { margin-bottom: 25px; }
.panel h2,
.section-bar h2 { margin: 0; font-size: 21px; }
.panel-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.safe-badge {
  padding: 8px 12px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.field {
  display: block;
  margin-top: 20px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field-grid .field { margin-top: 20px; }

.field-label {
  display: block;
  margin-bottom: 9px;
  color: #405148;
  font-size: 13px;
  font-weight: 650;
}

.field-label b { color: var(--red); }
.field-label small { margin-left: 5px; color: #98a39d; font-weight: 400; }

input, select, textarea {
  width: 100%;
  color: var(--ink);
  background: #f7f9f8;
  border: 1px solid #dde6e0;
  border-radius: 13px;
  outline: 0;
}

input, select {
  height: 50px;
  padding: 0 15px;
}

textarea {
  min-height: 92px;
  padding: 14px 15px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  background: #fff;
  border-color: #5aa17e;
  box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.09);
}

.consent-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin: 22px 2px 16px;
  color: #77847d;
  font-size: 12px;
  line-height: 1.6;
}

.consent-row input {
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 1px;
  accent-color: var(--green);
}

.primary-button,
.secondary-button,
.small-button,
.ghost-button,
.text-button {
  border: 0;
  border-radius: 12px;
  font-weight: 700;
}

.primary-button {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 12px 28px rgba(23, 107, 77, 0.18);
}

.primary-button:hover { background: #125f43; }
.primary-button:disabled { opacity: 0.55; cursor: wait; }
.link-button { text-align: center; }

.secondary-button {
  padding: 12px 18px;
  color: var(--green);
  background: var(--green-soft);
}

.small-button {
  padding: 8px 12px;
  color: #4f6b5d;
  background: #eef4f0;
  font-size: 12px;
}

.ghost-button {
  padding: 8px 13px;
  color: var(--green);
  background: transparent;
  border: 1px solid #cbd9d1;
}

.ghost-button.inverse {
  color: rgba(255, 255, 255, 0.82);
  border-color: rgba(255, 255, 255, 0.22);
}

.text-button {
  display: block;
  margin: 16px auto 0;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}

.success-panel {
  margin-top: 22px;
  padding: 34px;
  text-align: center;
}

.success-icon {
  display: flex;
  width: 66px;
  height: 66px;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  color: #fff;
  background: var(--green);
  border-radius: 22px;
  font-size: 32px;
}

.success-panel h2 { margin: 0; font-size: 28px; }
.success-panel p { margin: 10px auto 0; color: var(--muted); line-height: 1.7; }

.success-number {
  margin: 20px 0;
  padding: 15px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
}

.info-strip {
  margin-top: 20px;
  padding: 19px 22px;
}

.info-strip strong { color: #3e554a; font-size: 14px; }
.info-strip p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }

.site-footer {
  display: flex;
  width: min(760px, calc(100% - 40px));
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  padding: 0 0 36px;
  color: #89958f;
  font-size: 12px;
}

.site-footer a { color: #547664; }

/* Status */
.status-main {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.status-page .site-header {
  position: static;
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding-right: 0;
  padding-left: 0;
  transform: none;
  color: var(--ink);
}

.status-page .header-link { color: var(--green); border-color: #c9d8d0; }

.status-hero {
  padding: 34px;
  color: #fff;
  background: linear-gradient(145deg, #173d2f, #276b52);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.status-hero[data-status="pending"] { background: linear-gradient(145deg, #5d451b, #9b6c1f); }
.status-hero[data-status="rejected"] { background: linear-gradient(145deg, #673327, #9d4b39); }
.status-hero .eyebrow { color: rgba(255, 255, 255, 0.6); }
.status-hero h1 { margin: 16px 0 8px; font-size: 42px; }
.status-hero p { margin: 0; color: rgba(255, 255, 255, 0.75); line-height: 1.7; }

.status-badge {
  display: inline-flex;
  margin-top: 20px;
  padding: 8px 13px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  font-size: 12px;
}

.detail-panel,
.timeline-panel {
  margin-top: 18px;
  padding: 27px;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
  margin: 18px 0 0;
}

.detail-row {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #edf1ee;
}

.detail-row.wide { grid-column: 1 / -1; }
.detail-row dt { color: var(--muted); font-size: 13px; }
.detail-row dd { margin: 0; font-size: 14px; font-weight: 650; text-align: right; }

.timeline { margin-top: 22px; }

.timeline-item {
  position: relative;
  padding: 0 0 28px 34px;
}

.timeline-item::before {
  position: absolute;
  top: 9px;
  bottom: -2px;
  left: 8px;
  width: 2px;
  content: "";
  background: #dfe7e2;
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
  position: absolute;
  top: 4px;
  left: 1px;
  width: 16px;
  height: 16px;
  background: #aebbb4;
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #aebbb4;
}

.timeline-item.done .timeline-dot { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.timeline-item.current .timeline-dot { background: #d49525; box-shadow: 0 0 0 4px #fff0ca; }
.timeline-title { font-size: 15px; font-weight: 700; }
.timeline-time { margin-top: 6px; color: var(--muted); font-size: 12px; }
.timeline-note { margin-top: 9px; padding: 11px 13px; color: #5f7067; background: #f6f8f7; border-radius: 9px; font-size: 12px; line-height: 1.6; }

/* Login */
.login-page { background: linear-gradient(145deg, #102d22, #174d38); }

.login-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
}

.login-brand { margin-bottom: 22px; color: #fff; }
.login-panel { width: min(430px, 100%); padding: 38px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24); }
.login-panel h1 { margin: 14px 0 8px; font-size: 36px; }
.login-panel > p { margin: 0 0 25px; color: var(--muted); }
.back-link { display: block; margin-top: 21px; color: var(--muted); font-size: 13px; text-align: center; }
.login-links { display: grid; gap: 10px; margin-top: 21px; }
.login-links .back-link { margin-top: 0; }

/* Console */
.console-page { background: #f2f5f3; }

.console-header {
  padding: 0 clamp(20px, 4vw, 48px);
  color: #fff;
  background: #123b2d;
}

.user-box {
  display: flex;
  gap: 11px;
  align-items: center;
  color: rgba(255, 255, 255, 0.67);
  font-size: 12px;
}

.user-box strong { color: #fff; font-size: 14px; }

.console-main {
  width: min(1180px, calc(100% - 34px));
  margin: 0 auto;
  padding: 34px 0 60px;
}

.page-heading { margin-bottom: 28px; }
.page-heading h1 { margin: 10px 0 7px; font-size: 38px; }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.6; }

.metric {
  min-width: 124px;
  padding: 16px 22px;
  text-align: right;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.metric strong { display: block; color: var(--green); font-size: 34px; }
.metric span { color: var(--muted); font-size: 12px; }

.segmented {
  display: inline-flex;
  gap: 5px;
  margin-bottom: 18px;
  padding: 5px;
  background: #e6ece8;
  border-radius: 12px;
}

.segment {
  padding: 9px 16px;
  color: #6f7d76;
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
}

.segment.active { color: var(--green); background: #fff; box-shadow: 0 4px 12px rgba(30, 60, 46, 0.08); }

.record-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.record-card {
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 28px rgba(25, 57, 43, 0.04);
}

.record-top,
.record-footer,
.record-line {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.record-top { align-items: flex-start; }
.plate-large { font-size: 25px; font-weight: 850; letter-spacing: 1px; }
.record-cargo { margin-top: 9px; font-size: 16px; font-weight: 650; }
.record-meta { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.record-info { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-top: 17px; padding: 14px 0; border-top: 1px solid #edf1ee; border-bottom: 1px solid #edf1ee; }
.record-info span { color: var(--muted); font-size: 11px; }
.record-info strong { display: block; margin-top: 3px; font-size: 13px; }
.record-footer { margin-top: 15px; color: var(--muted); font-size: 11px; }

.record-actions { display: flex; gap: 8px; margin-top: 16px; }
.record-actions button { flex: 1; padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 700; }
.approve-button { color: #fff; background: var(--green); border: 0; }
.reject-button { color: var(--red); background: #fff4f1; border: 1px solid #edc7bd; }

.status-pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}

.status-pill.pending { color: #8e5d0d; background: #fff1d2; }
.status-pill.approved { color: var(--green); background: var(--green-soft); }
.status-pill.rejected { color: var(--red); background: #fde9e3; }

.query-panel { margin-bottom: 22px; padding: 23px 25px; }
.inline-field { display: flex; gap: 9px; }
.inline-field input { flex: 1; }
.compact { width: auto; min-height: 48px; padding: 0 18px; }
.hint { margin: 11px 0 0; color: var(--muted); font-size: 12px; }

.section-bar { margin: 27px 0 14px; }
.empty-card { padding: 56px 24px; color: #8c9992; text-align: center; }

.gate-record {
  padding: 21px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.gate-approved {
  display: inline-flex;
  padding: 6px 10px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}

.admin-stats { display: grid; gap: 18px; margin-bottom: 28px; }
.statistics-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.stat-card span { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin-top: 8px; color: var(--green); font-size: 34px; line-height: 1; }
.stat-card small { display: block; margin-top: 9px; color: var(--muted); font-size: 11px; }
.statistics-panels { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); gap: 18px; }
.statistics-panel { padding: 23px; }
.statistics-panel .panel-heading { margin-bottom: 18px; }
.weekly-statistics { display: grid; gap: 12px; }
.trend-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 98px; gap: 12px; align-items: center; }
.trend-date { color: var(--muted); font-size: 12px; }
.trend-track { height: 12px; overflow: hidden; background: #edf1ee; border-radius: 999px; }
.trend-fill { height: 100%; min-width: 0; background: var(--green); border-radius: 999px; transition: width 240ms ease; }
.trend-counts { color: var(--muted); font-size: 11px; text-align: right; white-space: nowrap; }
.approver-statistics { display: grid; gap: 12px; }
.approver-stat { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding-bottom: 11px; border-bottom: 1px solid #edf1ee; }
.approver-stat:last-child { padding-bottom: 0; border-bottom: 0; }
.approver-stat strong { font-size: 13px; }
.approver-stat span { color: var(--muted); font-size: 11px; text-align: right; line-height: 1.55; }
.emission-statistics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.emission-item { padding: 15px; background: #f6f9f7; border-radius: 13px; }
.emission-item span { color: var(--muted); font-size: 12px; }
.emission-item strong { display: block; margin-top: 6px; color: var(--green); font-size: 25px; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.dense-form .field { margin-top: 15px; }
.user-table { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.user-row { display: grid; grid-template-columns: 1.1fr 1.2fr 0.8fr 1.5fr auto; gap: 16px; align-items: center; padding: 16px 20px; border-bottom: 1px solid #edf1ee; }
.user-row:last-child { border-bottom: 0; }
.user-row header { font-size: 12px; color: var(--muted); }
.user-row strong { font-size: 14px; }
.user-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.role-badge { display: inline-flex; padding: 5px 9px; color: #355e4b; background: #eef5f1; border-radius: 999px; font-size: 11px; font-weight: 700; }
.toggle-user { padding: 7px 11px; color: var(--red); background: #fff3ef; border: 0; border-radius: 8px; font-size: 11px; }
.toggle-user.enable { color: var(--green); background: var(--green-soft); }

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 13px 17px;
  color: #fff;
  background: #173b2d;
  border-radius: 12px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.2);
  font-size: 13px;
}

.loading-card { width: min(720px, calc(100% - 32px)); margin: 40px auto; padding: 48px 24px; color: var(--muted); text-align: center; }

@media (max-width: 760px) {
  .site-header { min-height: 64px; padding: 0 18px; }
  .brand { font-size: 13px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 11px 11px 11px 4px; }
  .header-link { padding: 7px 11px; font-size: 11px; }
  .driver-hero { min-height: 350px; padding: 104px 24px 50px; border-radius: 0 0 30px 30px; }
  .driver-hero h1 { font-size: 39px; }
  .driver-hero p { font-size: 14px; }
  .form-panel { padding: 24px 20px; }
  .field-grid, .detail-list, .record-list { grid-template-columns: 1fr; }
  .statistics-cards, .statistics-panels, .emission-statistics { grid-template-columns: 1fr; }
  .trend-row { grid-template-columns: 64px minmax(0, 1fr) 90px; }
  .field-grid { gap: 0; }
  .detail-row.wide { grid-column: auto; }
  .console-header { padding: 0 16px; }
  .user-box > span { display: none; }
  .user-box { gap: 7px; }
  .console-main { width: calc(100% - 28px); padding-top: 24px; }
  .page-heading { align-items: flex-end; }
  .page-heading h1 { font-size: 32px; }
  .metric { min-width: 94px; padding: 12px 15px; }
  .metric strong { font-size: 27px; }
  .status-main { padding-top: 14px; }
  .status-hero { padding: 28px 24px; }
  .status-hero h1 { font-size: 35px; }
  .detail-panel, .timeline-panel { padding: 22px; }
  .inline-field { flex-wrap: wrap; }
  .inline-field input { flex-basis: 100%; }
  .inline-field .compact { flex: 1; }
  .user-row { grid-template-columns: 1fr auto; }
  .user-row > header { display: none; }
  .user-row > div:nth-child(2) { text-align: right; }
  .user-row > div:nth-child(3) { display: none; }
  .user-row > div:nth-child(4) { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
  .user-row > button { grid-column: 2; grid-row: 2; }
  .site-footer { width: calc(100% - 32px); }
  .login-panel { padding: 28px 22px; }
}
