:root {
  --green-950: #063c2d;
  --green-900: #084b39;
  --green-700: #196b52;
  --green-100: #e8f0ec;
  --gold: #c78b25;
  --gold-soft: #f6ead0;
  --ink: #202722;
  --muted: #747a75;
  --line: #e4dfd5;
  --paper: #fffdf9;
  --canvas: #f6f3ec;
  --danger: #9e4d43;
  --shadow: 0 12px 34px rgba(24, 44, 34, .08);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { color: var(--ink); font-family: Inter, "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 7px; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
.muted { color: var(--muted); }

.login-screen {
  display: grid;
  min-height: 100vh;
  padding: 44px;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 470px);
  gap: 8vw;
  align-items: center;
  background:
    linear-gradient(112deg, rgba(6, 60, 45, .98) 0 46%, rgba(6, 60, 45, .9) 46%, rgba(246, 243, 236, .96) 46%);
}
.login-brand { display: flex; align-items: center; justify-content: center; color: #fffaf0; }
.login-brand h1 { margin: 0; font-family: "Songti SC", STSong, serif; font-size: clamp(34px, 5vw, 64px); letter-spacing: .05em; }
.login-brand p { margin: 8px 0 0; color: #e1bc67; font-family: Georgia, serif; }
.brand-mark { display: grid; width: 94px; height: 94px; margin-right: 24px; place-items: center; color: var(--green-950); font-family: "Songti SC", serif; font-size: 56px; border-radius: 50%; background: #f0d28a; }
.brand-mark.small { width: 42px; height: 42px; margin-right: 12px; font-size: 25px; }
.login-card { padding: 42px; border: 1px solid rgba(6, 60, 45, .08); border-radius: 24px; background: rgba(255, 253, 249, .98); box-shadow: 0 24px 80px rgba(15, 39, 28, .18); }
.login-card h2 { margin: 0; color: var(--green-950); font-family: "Songti SC", serif; font-size: 32px; }
.login-card > label { display: grid; margin-top: 22px; gap: 8px; color: #4b554f; font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 11px 13px; color: var(--ink); border: 1px solid #d9d6cc; border-radius: 10px; outline: 0; background: #fff; }
input:focus, select:focus, textarea:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(25, 107, 82, .12); }
.primary-button, .secondary-button, .danger-button, .ghost-button {
  min-height: 40px; padding: 0 18px; border-radius: 22px; font-weight: 700; border: 1px solid transparent;
}
.primary-button { color: #fffaf0; background: var(--green-950); }
.primary-button:hover { background: var(--green-900); }
.secondary-button { color: var(--green-950); border-color: #b7c7bf; background: #fff; }
.danger-button { color: var(--danger); border-color: #dfc0bb; background: #fff7f5; }
.ghost-button { color: var(--green-950); background: var(--green-100); }
.login-card .primary-button { width: 100%; margin-top: 28px; }
.login-tip { margin: 16px 0 0; color: #8b8f89; font-size: 12px; text-align: center; }
.error-text { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 12px; text-align: center; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 236px 1fr; }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; padding: 22px 16px; flex-direction: column; color: #fffaf0; background: var(--green-950); }
.sidebar-brand { display: flex; padding: 5px 7px 25px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-family: "Songti SC", serif; font-size: 18px; }
.sidebar-brand span { margin-top: 4px; color: #d9b75f; font-size: 10px; }
.sidebar nav { display: grid; margin-top: 20px; gap: 6px; }
.sidebar nav button { display: flex; height: 44px; padding: 0 13px; align-items: center; color: rgba(255,255,255,.68); text-align: left; border: 0; border-radius: 10px; background: transparent; }
.sidebar nav button span { width: 32px; color: #d9b75f; font-family: Georgia, serif; font-size: 11px; }
.sidebar nav button:hover, .sidebar nav button.active { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-footer { display: grid; margin-top: auto; padding: 16px 8px 0; gap: 10px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-footer span { color: rgba(255,255,255,.62); font-size: 11px; }
.sidebar-footer button { padding: 0; color: #e0c98d; text-align: left; border: 0; background: transparent; }

.main { min-width: 0; }
.topbar { display: flex; min-height: 94px; padding: 22px 34px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,253,249,.94); }
.topbar h1 { margin: 0; color: var(--green-950); font-family: "Songti SC", serif; font-size: 28px; }
.operator { display: grid; text-align: right; }
.operator span { color: var(--gold); font-size: 11px; font-weight: 700; }
.operator strong { margin-top: 4px; font-size: 14px; }
.content { padding: 28px 34px 50px; }
.view-toolbar { display: flex; margin-bottom: 18px; gap: 12px; align-items: center; justify-content: space-between; }
.toolbar-group { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.toolbar-group input, .toolbar-group select { width: auto; min-width: 150px; }
.section-card { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 4px 15px rgba(25,44,34,.035); }
.section-card + .section-card { margin-top: 18px; }
.section-header { display: flex; min-height: 62px; padding: 15px 18px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.section-header h2 { margin: 0; color: var(--green-950); font-family: "Songti SC", serif; font-size: 20px; }
.section-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }

.metric-grid { display: grid; margin-bottom: 18px; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; }
.metric-card { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 8px; color: var(--green-950); font-family: Georgia, "Songti SC", serif; font-size: 29px; }
.metric-card em { display: block; margin-top: 7px; color: var(--gold); font-size: 11px; font-style: normal; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 12px 14px; color: #788079; font-size: 11px; font-weight: 700; text-align: left; border-bottom: 1px solid var(--line); background: #faf8f2; }
.data-table td { padding: 13px 14px; font-size: 12px; vertical-align: middle; border-bottom: 1px solid #eee9df; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #fbfaf6; }
.data-table .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.data-table .actions button { min-height: 28px; padding: 0 10px; font-size: 11px; border-radius: 16px; }
.table-checkbox { width: 17px; height: 17px; margin: 0; accent-color: var(--green-900); }
.delivery-table th:first-child, .delivery-table td:first-child { width: 42px; text-align: center; }
.delivery-table .delivery-address { min-width: 190px; max-width: 280px; line-height: 1.55; }
.delivery-table .delivery-phone { color: var(--green-950); font-size: 13px; font-weight: 700; }
.product-cell { display: flex; min-width: 210px; align-items: center; }
.product-thumb { width: 48px; height: 48px; margin-right: 11px; flex-shrink: 0; object-fit: cover; border-radius: 9px; background: #eee9df; }
.product-cell strong, .product-cell span { display: block; }
.product-cell span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.status-badge { display: inline-flex; min-height: 24px; padding: 0 9px; align-items: center; color: var(--green-900); font-size: 10px; font-weight: 700; border-radius: 14px; background: var(--green-100); }
.status-badge.gold { color: #845918; background: var(--gold-soft); }
.status-badge.muted { color: #6d726d; background: #ecece8; }
.status-badge.danger { color: var(--danger); background: #fae9e6; }
.status-badge.workflow-pending { color: #fff; background: #b94f46; }
.status-badge.workflow-shipping { color: #fff; background: #197052; }
.status-badge.workflow-delivered { color: #606761; background: #e1e3e1; }
.status-badge.role-badge { min-height: 28px; padding: 0 12px; color: #fff; font-size: 11px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
.role-badge-superadmin { background: #9b6718; }
.role-badge-manager { background: #0b684a; }
.role-badge-clerk { background: #39729a; }
.role-badge-finance { background: #79528f; }
.role-badge-delivery { background: #c45f28; }
.shipment-actions { min-width: 76px; justify-content: flex-start; }
.data-table .actions .ship-order { color: #fffaf0; border: 1px solid #0d5a40; background: var(--green-900); }
.data-table .actions .ship-order:hover { background: var(--green-700); }
.data-table .actions .verify-pickup { min-width: 76px; color: #fffaf0; font-size: 14px; font-weight: 800; letter-spacing: 2px; border: 1px solid #0d5a40; background: var(--green-900); }
.data-table .actions .verify-pickup:hover { background: var(--green-700); }
.empty-state { padding: 55px 20px; color: var(--muted); text-align: center; }

.split-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .8fr); gap: 18px; }
.split-grid > .section-card + .section-card { margin-top: 0; }
.category-list { padding: 9px 16px; }
.category-row { display: grid; min-height: 54px; grid-template-columns: 1fr 90px auto; gap: 9px; align-items: center; border-bottom: 1px solid var(--line); }
.category-row:last-child { border-bottom: 0; }
.category-row span { color: var(--muted); font-size: 11px; }
.category-row .actions { display: flex; gap: 6px; }

.chart { display: flex; min-height: 240px; padding: 22px 18px 10px; gap: 10px; align-items: flex-end; overflow-x: auto; }
.bar-column { display: grid; min-width: 48px; height: 210px; align-content: end; justify-items: center; }
.bar-column strong { margin-bottom: 5px; color: var(--green-950); font-size: 10px; }
.bar { width: 28px; min-height: 3px; border-radius: 7px 7px 0 0; background: var(--green-700); }
.bar-column span { margin-top: 7px; color: var(--muted); font-size: 9px; }

.modal { width: min(720px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 18px; background: transparent; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(8, 30, 21, .48); backdrop-filter: blur(3px); }
.modal-card { overflow: hidden; border-radius: 18px; background: var(--paper); }
.modal-card > header { display: flex; min-height: 72px; padding: 17px 20px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-card h2 { margin: 0; color: var(--green-950); font-family: "Songti SC", serif; }
.icon-button { width: 34px; height: 34px; color: var(--muted); font-size: 24px; border: 0; border-radius: 50%; background: #f1efe8; }
.modal-body { max-height: 65vh; padding: 20px; overflow: auto; }
.modal-card > footer { display: flex; padding: 15px 20px; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }
.message-modal { width: min(470px, calc(100vw - 32px)); }
.message-card > header { min-height: 66px; }
.message-text { margin: 0; color: #303a34; font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
.message-field { display: grid; margin-top: 18px; gap: 8px; color: #535c56; font-size: 12px; font-weight: 600; }
.message-field input { width: 100%; }
.message-card > footer button { min-width: 92px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid label { display: grid; gap: 7px; color: #535c56; font-size: 12px; font-weight: 600; }
.form-grid .span-2 { grid-column: span 2; }
.employee-delete-zone { display: flex; min-height: 72px; padding: 14px 16px; box-sizing: border-box; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid #ead0cb; border-radius: 12px; background: #fff7f5; }
.employee-delete-zone div { display: grid; gap: 5px; }
.employee-delete-zone strong { color: #8f3f37; font-size: 13px; }
.employee-delete-zone span { color: #83716d; font-size: 11px; line-height: 1.45; }
.employee-delete-zone .danger-button { flex-shrink: 0; }
.employee-delete-zone .danger-button:disabled { cursor: not-allowed; opacity: .45; }
.checkbox-line { display: flex !important; align-items: center; gap: 8px !important; }
.checkbox-line input { width: auto; }
.image-preview { width: 100px; height: 100px; object-fit: cover; border: 1px solid var(--line); border-radius: 12px; background: #eee9df; }
.banner-thumb { width: 168px; height: 94px; object-fit: cover; border: 1px solid var(--line); border-radius: 12px; background: #eee9df; }
.banner-preview { width: 100%; max-height: 280px; margin-top: 8px; object-fit: cover; border: 1px solid var(--line); border-radius: 14px; background: #eee9df; }
.spec-unit-text { font-size: 1.5em !important; font-weight: 700 !important; }
#purchaseProduct { font-size: 18px; font-weight: 700; }
.order-detail { display: grid; gap: 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.detail-grid div { padding: 11px; border-radius: 10px; background: #f6f3ec; }
.detail-grid span, .detail-grid strong { display: block; }
.detail-grid span { color: var(--muted); font-size: 10px; }
.detail-grid strong { margin-top: 5px; font-size: 12px; }
.timeline { display: grid; gap: 10px; }
.timeline-item { display: grid; grid-template-columns: 110px 90px 1fr; gap: 10px; font-size: 11px; }
.timeline-item time { color: var(--muted); }

.inventory-top-grid { margin-bottom: 18px; grid-template-columns: minmax(420px, .9fr) minmax(520px, 1.25fr); }
.inventory-purchase-form { display: grid; padding: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.inventory-purchase-form label { display: grid; gap: 7px; color: #535c56; font-size: 12px; font-weight: 600; }
.inventory-purchase-form .span-2 { grid-column: span 2; }
.inventory-form-footer { display: flex !important; min-height: 52px; gap: 15px; align-items: center; justify-content: space-between; }
.inventory-form-footer .muted { max-width: 62%; font-size: 10px; line-height: 1.5; }
.inventory-compact-table td { padding: 11px 12px; font-size: 11px; }

.permission-role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.permission-role-card { display: flex; min-height: 520px; flex-direction: column; }
.permission-role-card .section-header .actions { display: flex; gap: 7px; }
.permission-groups { display: grid; padding: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.permission-group { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.permission-group legend { padding: 0 6px; color: var(--green-950); font-size: 12px; font-weight: 700; }
.permission-option { display: flex; min-height: 46px; padding: 7px 5px; gap: 9px; align-items: flex-start; border-bottom: 1px solid #eee9df; cursor: pointer; }
.permission-option:last-child { border-bottom: 0; }
.permission-option input { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; accent-color: var(--green-900); }
.permission-option span, .permission-option strong, .permission-option small { display: block; min-width: 0; }
.permission-option strong { color: #313a34; font-size: 11px; line-height: 1.35; }
.permission-option small { margin-top: 3px; overflow: hidden; color: var(--muted); font-family: ui-monospace, monospace; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.permission-option:has(input:disabled) { cursor: default; opacity: .78; }
.permission-footer { display: flex; min-height: 68px; margin-top: auto; padding: 13px 18px; gap: 14px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); background: #faf8f2; }
.permission-footer .muted { max-width: 60%; font-size: 10px; line-height: 1.45; }

.toast { position: fixed; top: 50%; left: 50%; z-index: 200; max-width: min(360px, calc(100vw - 40px)); padding: 15px 20px; color: #fff; font-size: 13px; line-height: 1.5; text-align: center; border-radius: 12px; background: var(--green-950); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, -50%) scale(.94); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.error { background: var(--danger); }

@media (max-width: 980px) {
  .login-screen { grid-template-columns: 1fr; background: var(--green-950); }
  .login-brand { display: none; }
  .login-card { width: min(470px, 100%); margin: auto; }
  .app-shell { grid-template-columns: 78px 1fr; }
  .sidebar { padding-right: 10px; padding-left: 10px; }
  .sidebar-brand > div:last-child, .sidebar nav button:not(.active) { font-size: 0; }
  .sidebar nav button { justify-content: center; font-size: 0; }
  .sidebar nav button span { width: auto; font-size: 12px; }
  .sidebar-footer span { display: none; }
  .split-grid { grid-template-columns: 1fr; }
  .inventory-top-grid { grid-template-columns: 1fr; }
  .permission-role-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .content, .topbar { padding-right: 16px; padding-left: 16px; }
  .metric-grid { grid-template-columns: 1fr; }
  .view-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-group input, .toolbar-group select { width: 100%; }
  .section-card { overflow-x: auto; }
  .data-table { min-width: 760px; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .inventory-purchase-form { grid-template-columns: 1fr; }
  .inventory-purchase-form .span-2 { grid-column: span 1; }
  .permission-groups { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}
