:root {
  --background: #f7f8fa;
  --foreground: #15171a;
  --card: #ffffff;
  --primary: #17191c;
  --primary-foreground: #ffffff;
  --muted: #f3f4f6;
  --muted-foreground: #6d727a;
  --accent: #fff5d8;
  --accent-strong: #dfaa00;
  --success: #15805d;
  --warning: #a15c00;
  --danger: #c4322b;
  --border: #e5e7eb;
  --input: #dfe2e6;
  --sidebar-width: 278px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .16);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", sans-serif;
  color: var(--foreground);
  background: var(--background);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--background); color: var(--foreground); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #6b7280; outline-offset: 2px; }
svg { display: block; width: 18px; height: 18px; stroke-width: 1.8; }
.hidden { display: none !important; }
.muted { color: var(--muted-foreground); }

.app-loading { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted-foreground); }
.spinner { width: 24px; height: 24px; border: 2px solid #d8dadd; border-top-color: var(--foreground); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand-mark { display: inline-grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 17px; font-weight: 800; }
.brand-mark-light { background: #fff; color: #15171a; }
.brand-lockup, .mobile-brand { display: flex; align-items: center; gap: 11px; font-size: 16px; font-weight: 700; }
.eyebrow { display: block; margin-bottom: 7px; color: #7d838c; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow-light { color: rgba(255,255,255,.58); }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 46%) 1fr; background: #fff; }
.login-brand-panel { min-height: 100vh; padding: 46px 54px; display: flex; flex-direction: column; position: relative; overflow: hidden; color: #fff; background: radial-gradient(circle at 78% 15%, rgba(255,255,255,.08), transparent 30%), linear-gradient(150deg, #101215 0%, #191d21 64%, #20262a 100%); }
.login-brand-panel::after { content: ""; position: absolute; width: 480px; height: 480px; right: -280px; bottom: -210px; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.018), 0 0 0 140px rgba(255,255,255,.012); }
.login-brand-copy { margin: auto 0; position: relative; z-index: 1; max-width: 520px; }
.login-brand-copy h1 { margin: 0 0 24px; font-size: clamp(40px,4.4vw,64px); line-height: 1.08; letter-spacing: -.055em; font-weight: 650; }
.login-brand-copy p { max-width: 450px; margin: 0; color: rgba(255,255,255,.63); font-size: 16px; line-height: 1.75; }
.login-brand-footer { position: relative; z-index: 1; margin: 0; color: rgba(255,255,255,.36); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.login-form-panel { display: grid; place-items: center; min-height: 100vh; padding: 44px; }
.login-card { width: min(100%,400px); }
.mobile-brand { display: none; margin-bottom: 48px; }
.login-card h2 { margin: 0 0 7px; font-size: 28px; letter-spacing: -.035em; }
.login-card .field-group:first-of-type { margin-top: 30px; }
.login-card .button-full { margin-top: 22px; }
.form-note { margin: 18px 0 0; text-align: center; color: #92979e; font-size: 12px; }

.field-group { display: grid; align-content: start; gap: 7px; }
.field-group label { color: #363a40; font-size: 13px; font-weight: 700; }
.field-group small { color: var(--muted-foreground); font-size: 11px; }
input, select, textarea { width: 100%; border: 1px solid var(--input); border-radius: 10px; outline: none; padding: 0 12px; color: var(--foreground); background: #fff; box-shadow: var(--shadow-sm); }
input, select { height: 44px; }
.locked-field { align-items: center; background: #f3f5f7; border: 1px solid var(--input); border-radius: 10px; color: var(--muted-foreground); display: flex; min-height: 44px; padding: 0 12px; }
textarea { padding-top: 11px; padding-bottom: 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #34373b; box-shadow: 0 0 0 3px rgba(25,28,31,.09); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 48px; }
.password-toggle { position: absolute; top: 5px; right: 5px; }

.button { height: 44px; border: 1px solid transparent; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; font-size: 14px; font-weight: 700; line-height: 1; transition: background .15s,border-color .15s,transform .05s; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .58; cursor: not-allowed; transform: none; }
.button svg { width: 16px; height: 16px; }
.button-primary { background: var(--primary); color: var(--primary-foreground); }
.button-primary:hover { background: #2a2d31; }
.button-outline { background: #fff; border-color: var(--border); color: #383c42; }
.button-outline:hover { background: #f7f8f9; border-color: #d6d9dd; }
.button-large { height: 48px; font-size: 15px; font-weight: 800; }
.button-small { height: 44px; font-size: 14px; font-weight: 700; }
.button-full { width: 100%; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 50%; display: inline-grid; place-items: center; padding: 0; background: transparent; }
.icon-button:hover { background: var(--muted); }

.alert { margin-top: 20px; padding: 11px 13px; border-radius: 10px; font-size: 13px; }
.alert-error { color: #9e2b25; background: #fff1f0; border: 1px solid #f5cfcc; }

.dashboard-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0,1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar-width); display: flex; flex-direction: column; padding: 22px 18px 16px; background: #fff; border-right: 1px solid var(--border); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 24px; }
.sidebar-brand-copy { display: grid; }
.sidebar-brand-copy strong { font-size: 15px; }
.sidebar-brand-copy small { color: var(--muted-foreground); font-size: 11px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { margin: 9px 12px 7px; color: #9a9ea5; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-label-spaced { margin-top: 24px; }
.nav-item { width: 100%; height: 42px; border: 0; border-radius: 10px; display: flex; align-items: center; gap: 11px; padding: 0 12px; color: #565b62; background: transparent; text-align: left; font-weight: 650; }
.nav-item:hover { background: #f6f7f8; color: #202327; }
.nav-item.active { background: #eceef0; color: #17191c; }
.nav-item .nav-count { margin-left: auto; min-width: 23px; padding: 2px 7px; border-radius: 999px; color: #715500; background: var(--accent); text-align: center; font-size: 11px; }
.sidebar-footer { margin-top: auto; }
.sidebar-user { width: 100%; min-height: 58px; border: 1px solid transparent; border-radius: 12px; display: flex; align-items: center; gap: 10px; padding: 8px; background: transparent; text-align: left; }
.sidebar-user:hover { border-color: var(--border); background: #fafafa; }
.sidebar-user-copy { display: grid; min-width: 0; flex: 1; }
.sidebar-user-copy strong, .sidebar-user-copy span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sidebar-user-copy span { color: var(--muted-foreground); font-size: 11px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: #202327; color: #fff; font-size: 12px; font-weight: 800; }
.avatar-sm { width: 32px; height: 32px; }
.account-menu { position: absolute; left: 18px; bottom: 82px; width: 242px; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: var(--shadow-lg); }
.account-menu-header { display: flex; align-items: center; gap: 10px; padding: 9px; }
.account-menu-header > div:last-child { min-width: 0; display: grid; }
.account-menu-header span { color: var(--muted-foreground); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.account-menu-item { width: 100%; height: 40px; border: 0; border-radius: 9px; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: transparent; }
.account-menu-item:hover { background: var(--muted); }

.main-column { grid-column: 2; min-width: 0; }
.topbar { height: 70px; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; background: rgba(247,248,250,.92); border-bottom: 1px solid rgba(229,231,235,.9); backdrop-filter: blur(14px); }
.breadcrumb { display: flex; align-items: center; gap: 8px; color: #8a8f97; font-size: 12px; }
.breadcrumb i { color: #c0c3c7; font-style: normal; }
.breadcrumb strong { color: #33373c; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.status-dot-wrap { display: flex; align-items: center; gap: 7px; color: #71767d; font-size: 11px; }
.status-dot-wrap i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(21,128,93,.1); }
.mobile-menu { display: none; }
.main-content { max-width: 1500px; margin: 0 auto; padding: 36px 38px 70px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.page-heading h1 { margin: 0 0 5px; font-size: 30px; letter-spacing: -.04em; }
.page-heading p { margin: 0; }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.metrics-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { min-height: 136px; padding: 22px; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: var(--shadow-sm); }
.metric-card-top { display: flex; justify-content: space-between; color: #777c83; font-weight: 650; }
.metric-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #8c6900; background: var(--accent); }
.metric-card strong { display: block; margin-top: 14px; font-size: 30px; letter-spacing: -.04em; }
.metric-card small { color: var(--muted-foreground); }

.card { border: 1px solid var(--border); border-radius: 14px; background: var(--card); box-shadow: var(--shadow-sm); }
.card-header { padding: 21px 22px; border-bottom: 1px solid var(--border); }
.card-header-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.card-header h2 { margin: 0 0 3px; font-size: 17px; }
.card-header p { margin: 0; color: var(--muted-foreground); font-size: 12px; }
.toolbar { min-height: 74px; display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.toolbar-filter { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted-foreground); font-size: 12px; font-weight: 700; }
.search-wrap { position: relative; flex: 1; max-width: 520px; }
.search-wrap svg { position: absolute; top: 13px; left: 13px; color: #9ba0a7; }
.search-wrap input { padding-left: 40px; }
.toolbar select { width: 170px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; border-bottom: 1px solid #eceef0; text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: #777c83; background: #fafbfc; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfd; }
.table-primary { font-weight: 750; }
.table-secondary { display: block; color: var(--muted-foreground); font-size: 11px; }
.table-actions { display: flex; justify-content: flex-end; gap: 7px; }
.table-action { height: 44px; border: 1px solid var(--border); border-radius: 999px; padding: 0 16px; background: #fff; font-size: 14px; font-weight: 700; }
.table-action:hover { background: var(--muted); }
.order-number-link { border: 0; padding: 0; color: inherit; background: transparent; text-align: left; }
.order-number-link .table-primary { text-decoration: underline; text-decoration-color: #cfd2d6; text-underline-offset: 3px; }
.order-number-link:hover .table-primary { text-decoration-color: currentColor; }
.quantity { font-size: 18px; font-weight: 800; }
.quantity-unit { margin-left: 3px; color: var(--muted-foreground); font-size: 11px; font-weight: 700; }
.badge { display: inline-flex; align-items: center; height: 25px; padding: 0 9px; border-radius: 999px; background: #f0f1f2; color: #555a61; font-size: 11px; font-weight: 800; }
.badge-success { color: #116447; background: #e8f6ef; }
.badge-warning { color: #855100; background: #fff4d8; }
.badge-danger { color: #9b2d27; background: #fff0ee; }
.empty-state { padding: 55px 20px; color: var(--muted-foreground); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: #3f4348; font-size: 15px; }
.management-empty { min-height: 300px; padding: 54px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted-foreground); text-align: center; }
.management-empty-icon { width: 48px; height: 48px; margin-bottom: 16px; border-radius: 14px; display: grid; place-items: center; color: #876600; background: var(--accent); }
.management-empty-icon svg { width: 22px; height: 22px; }
.management-empty strong { margin-bottom: 5px; color: #3f4348; font-size: 15px; }
.management-empty > span:last-child { max-width: 470px; }

.modal-dialog { width: min(760px,calc(100vw - 32px)); max-height: calc(100vh - 40px); border: 0; border-radius: 16px; padding: 0; background: #fff; box-shadow: var(--shadow-lg); }
.modal-dialog::backdrop { background: rgba(15,18,22,.48); backdrop-filter: blur(2px); }
.modal-card { display: grid; max-height: calc(100vh - 40px); }
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 22px; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 20px; }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--border); }
.modal-body { overflow-y: auto; padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.form-span { grid-column: 1 / -1; }

body.order-detail-open { overflow: hidden; }
.order-detail-drawer { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: flex-end; }
.order-detail-backdrop { position: absolute; inset: 0; border: 0; padding: 0; background: rgba(15,18,22,.44); opacity: 0; transition: opacity .18s ease; backdrop-filter: blur(1px); }
.order-detail-panel { position: relative; width: min(620px,100vw); height: 100%; display: grid; grid-template-rows: auto minmax(0,1fr); background: #fff; box-shadow: -18px 0 50px rgba(16,24,40,.16); transform: translateX(100%); transition: transform .18s ease; }
.order-detail-drawer.open .order-detail-backdrop { opacity: 1; }
.order-detail-drawer.open .order-detail-panel { transform: translateX(0); }
.order-detail-header { min-height: 91px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 22px; border-bottom: 1px solid var(--border); background: #fff; }
.order-detail-header .eyebrow { margin-bottom: 2px; }
.order-detail-header h2 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.order-detail-header p { margin: 2px 0 0; color: var(--muted-foreground); font-size: 11px; }
.order-detail-close { flex: 0 0 auto; background: var(--muted); }
.order-detail-content { min-height: 0; overflow-y: auto; padding: 20px 22px 34px; background: #f8f9fa; }
.order-detail-loading, .order-detail-error { min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted-foreground); text-align: center; }
.order-detail-loading strong, .order-detail-error strong { color: #3f4348; }
.order-detail-error > svg { width: 28px; height: 28px; color: var(--warning); }
.order-detail-status-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; margin-bottom: 14px; }
.order-detail-status-grid > div { min-height: 70px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.order-detail-status-grid > div > span:first-child { color: var(--muted-foreground); font-size: 11px; font-weight: 700; }
.order-detail-section { margin-top: 14px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: var(--shadow-sm); }
.order-detail-section h3 { margin: 0 0 13px; font-size: 14px; }
.order-detail-items { display: grid; gap: 11px; }
.order-detail-item { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; }
.order-detail-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 14px; }
.order-detail-item-head > div:first-child { min-width: 0; display: grid; gap: 3px; }
.order-detail-item-head strong { white-space: normal; }
.order-detail-item-head span { color: var(--muted-foreground); font-size: 11px; }
.order-detail-item-price { flex: 0 0 auto; display: grid; justify-items: end; gap: 4px; }
.order-detail-components { padding: 12px 14px; border-top: 1px solid var(--border); background: #f6f7f8; }
.order-detail-components > span { display: block; margin-bottom: 7px; color: var(--muted-foreground); font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.order-detail-components > div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; }
.order-detail-components strong { font-size: 12px; font-weight: 650; }
.order-detail-components b { flex: 0 0 auto; font-size: 12px; }
.order-detail-item-deposit { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border-top: 1px solid #f1dfab; color: #674d00; background: #fff8e5; }
.order-detail-item-deposit > div:first-child { display: grid; }
.order-detail-item-deposit span { font-size: 12px; font-weight: 800; }
.order-detail-item-deposit small { color: #8b6c16; font-size: 10px; }
.order-detail-summary { display: grid; gap: 9px; }
.order-detail-summary-row, .order-detail-summary-total { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
.order-detail-summary-row { color: #545960; font-size: 12px; }
.order-detail-summary-row.is-discount { color: var(--danger); }
.order-detail-summary-total { margin-top: 4px; padding-top: 13px; border-top: 2px solid #e4e6e8; font-size: 16px; font-weight: 800; }
.money-value { display: inline-flex; align-items: baseline; justify-content: flex-end; color: inherit; white-space: nowrap; font-weight: 800; }
.money-integer { font-size: 1em; }
.money-affix { font-size: 70%; }
.order-detail-summary-total .money-value { font-size: 22px; }
.order-detail-info { display: grid; gap: 0; }
.order-detail-info-row { display: grid; grid-template-columns: 110px minmax(0,1fr); gap: 14px; padding: 9px 0; border-bottom: 1px solid #eff0f1; }
.order-detail-info-row:last-child { border-bottom: 0; }
.order-detail-info-row > span { color: var(--muted-foreground); font-size: 11px; }
.order-detail-info-row strong { min-width: 0; font-size: 12px; overflow-wrap: anywhere; }
.order-detail-multiline, .order-detail-note { white-space: pre-line; }
.order-detail-note { margin: 0; color: #4f545b; font-size: 12px; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: grid; gap: 10px; }
.toast { width: min(360px,calc(100vw - 44px)); display: flex; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid #cce8dd; border-radius: 12px; background: #fff; box-shadow: var(--shadow-lg); }
.toast > svg { color: var(--success); }
.toast strong { display: block; }
.toast p { margin: 2px 0 0; color: var(--muted-foreground); font-size: 12px; }
.toast-error { border-color: #f2cac6; }
.toast-error > svg { color: var(--danger); }
.mobile-overlay { display: none; }

@media (max-width: 1050px) {
  .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 780px) {
  .login-page { display: block; padding: 30px 22px; }
  .login-brand-panel { display: none; }
  .login-form-panel { min-height: calc(100vh - 60px); padding: 0; }
  .mobile-brand { display: flex; }
  .dashboard-shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main-column { width: 100%; }
  .mobile-menu { display: inline-grid; }
  .mobile-overlay { position: fixed; inset: 0; z-index: 25; display: block; border: 0; background: rgba(15,18,22,.42); }
  .topbar { padding: 0 18px; }
  .topbar .breadcrumb span, .topbar .breadcrumb i, .status-dot-wrap { display: none; }
  .main-content { padding: 26px 18px 60px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading h1 { font-size: 26px; }
  .heading-actions { width: 100%; }
  .heading-actions .button { flex: 1; }
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 118px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-filter { width: 100%; margin-left: 0; justify-content: space-between; }
  .toolbar select, .search-wrap { width: 100%; max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-span { grid-column: auto; }
  .modal-footer .button { flex: 1; }
  .order-detail-panel { width: 100vw; }
  .order-detail-content { padding: 16px 14px 28px; }
  .order-detail-header { padding: 16px 17px; }
  .order-detail-status-grid { grid-template-columns: 1fr; }
  .order-detail-status-grid > div { min-height: 54px; flex-direction: row; align-items: center; }
  .order-detail-section { padding: 15px; }
  .order-detail-item-head { gap: 10px; }
  .order-detail-info-row { grid-template-columns: 90px minmax(0,1fr); }
}
