:root {
  --ink: #18233f;
  --muted: #657087;
  --line: #e5e9f2;
  --surface: #ffffff;
  --page: #f5f7fb;
  --accent: #6d4dc6;
  --accent-dark: #512daa;
  --accent-soft: #f0ebff;
  --blue: #126f90;
  --blue-soft: #e4f7fb;
  --danger: #d84050;
  --danger-soft: #fde8ea;
  --warning: #b46d00;
  --warning-soft: #fff2d7;
  --success: #168759;
  --success-soft: #e5f8ef;
  --shadow: 0 12px 35px rgba(26, 34, 61, .08);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--page); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

/* Public screen */
.public-header { position: sticky; z-index: 5; top: 0; background: #fff; min-height: 78px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 12px clamp(18px, 3vw, 52px); }
.brand, .admin-brand { display: inline-flex; align-items: center; gap: 14px; font-weight: 800; letter-spacing: -.02em; }
.brand img { width: 54px; height: 42px; object-fit: contain; object-position: center; }
.brand span { font-size: clamp(18px, 2vw, 25px); }
.admin-link { border: 1px solid var(--accent); color: var(--accent); background: white; padding: 9px 14px; border-radius: 10px; font-size: 14px; font-weight: 700; }
.admin-link:hover { background: var(--accent-soft); }
.public-main { width: min(1600px, calc(100% - 40px)); margin: 28px auto 44px; }
.screen-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.screen-intro h1 { margin: 0; font-size: clamp(26px, 3.3vw, 42px); letter-spacing: -.035em; }
.screen-intro p { margin: 8px 0 0; color: var(--muted); }
.refresh-note { align-self: center; color: var(--muted); font-size: 14px; white-space: nowrap; }
.order-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; }
.public-order-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.card-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding: 22px 22px 16px; border-bottom: 1px solid var(--line); }
.card-title { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.card-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 9px; }
.card-body { padding: 18px 22px 21px; }
.public-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.public-order-table, .data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
.public-order-table th, .public-order-table td, .data-table th, .data-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.public-order-table th, .data-table th { background: #fafbfe; color: #37425a; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
.public-order-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.table-strong { font-weight: 800; }
.inline-note { color: var(--muted); display: block; margin-top: 3px; }
.card-summary { display: flex; gap: 20px; flex-wrap: wrap; padding: 16px 0 0; color: var(--muted); }
.card-summary strong { color: var(--ink); display: block; margin-top: 3px; font-size: 18px; }
.view-order-button { display: inline-flex; margin-top: 17px; align-items: center; justify-content: center; padding: 10px 15px; border: 1px solid var(--accent); color: var(--accent); border-radius: 10px; font-weight: 800; }
.view-order-button:hover { background: var(--accent-soft); }
.empty-state { background: white; border: 1px dashed #cfd6e5; padding: 58px 24px; border-radius: 16px; text-align: center; color: var(--muted); }
.public-detail { width: min(1220px, calc(100% - 40px)); margin: 28px auto 44px; }
.detail-back { display: inline-flex; color: var(--accent); font-weight: 800; margin-bottom: 16px; }
.detail-card { background: white; box-shadow: var(--shadow); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.detail-head { padding: 26px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; }
.detail-head h1 { margin: 0; font-size: clamp(26px, 3vw, 38px); }
.detail-body { padding: 26px; }
.notes-box { background: #fafbfe; border: 1px solid var(--line); padding: 15px; border-radius: 12px; color: #39435c; white-space: pre-line; }
.images-grid { margin-top: 22px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.images-grid a { display: block; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #f9f9fb; }
.images-grid img { height: 210px; width: 100%; object-fit: cover; display: block; }
.public-footer { padding: 22px 18px 30px; text-align: center; color: var(--muted); font-size: 13px; }

.status { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status.primary { background: #e9e4ff; color: #5439aa; }
.status.warning { background: var(--warning-soft); color: var(--warning); }
.status.danger { background: var(--danger-soft); color: var(--danger); }
.status.success { background: var(--success-soft); color: var(--success); }
.status.muted { background: #eceff5; color: #586174; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-card { width: min(440px, 100%); background: white; padding: 34px; box-shadow: var(--shadow); border: 1px solid var(--line); border-radius: 18px; }
.login-logo { text-align: center; }
.login-logo img { width: 104px; height: 76px; object-fit: contain; }
.login-card h1 { text-align: center; margin: 12px 0 8px; font-size: 28px; }
.login-card p { text-align: center; color: var(--muted); margin: 0 0 25px; }

/* Admin */
.admin-header { height: 68px; padding: 8px 25px; background: white; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.admin-brand img { width: 52px; height: 47px; object-fit: contain; }
.admin-brand span { font-size: 18px; }
.user-menu { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 14px; }
.text-button { border: none; background: transparent; padding: 0; color: var(--accent); font-weight: 800; }
.admin-layout { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 230px 1fr; }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar a { color: #4b5570; font-weight: 700; font-size: 14px; padding: 11px 12px; border-radius: 9px; }
.sidebar a:hover, .sidebar a.active { background: var(--accent-soft); color: var(--accent-dark); }
.admin-content { padding: 28px clamp(20px, 3vw, 44px) 52px; min-width: 0; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-title h1 { margin: 0; font-size: 26px; letter-spacing: -.025em; }
.page-title p { margin: 6px 0 0; color: var(--muted); }
.section-card { background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 24px rgba(34, 43, 75, .04); padding: 22px; margin-bottom: 20px; }
.section-card h2 { margin: 0 0 15px; font-size: 18px; }
.section-card h3 { margin: 0 0 12px; font-size: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: white; border: 1px solid var(--line); padding: 18px; border-radius: 14px; }
.kpi .label { color: var(--muted); font-weight: 700; font-size: 13px; }
.kpi .value { margin-top: 6px; font-size: 28px; font-weight: 900; letter-spacing: -.04em; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-select, .search-field { min-height: 38px; border: 1px solid #d8deea; padding: 0 10px; border-radius: 8px; color: var(--ink); background: white; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: 9px; font-weight: 800; font-size: 14px; transition: .15s; }
.btn.primary { color: #fff; background: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.secondary { color: var(--accent); border-color: var(--accent); background: #fff; }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.danger { color: #fff; background: var(--danger); }
.btn.danger:hover { filter: brightness(.92); }
.btn.small { min-height: 32px; font-size: 12px; padding: 0 10px; }
.action-group { display: flex; gap: 7px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.data-table { min-width: 900px; font-size: 14px; }
.data-table .notes { max-width: 280px; color: var(--muted); white-space: pre-line; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid.triple { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 800; color: #3b455c; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #d9dfec; border-radius: 9px; padding: 10px 11px; color: var(--ink); background: #fff; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #eee9ff; }
.field textarea { min-height: 96px; resize: vertical; }
.help { color: var(--muted); font-size: 12px; line-height: 1.4; }
.form-actions { margin-top: 22px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 18px; font-weight: 700; }
.flash.success { background: var(--success-soft); color: #126b48; border: 1px solid #bee8d1; }
.flash.error { background: var(--danger-soft); color: #aa2231; border: 1px solid #f3c4cb; }
.order-item { border: 1px solid var(--line); border-radius: 14px; padding: 17px; margin-bottom: 16px; background: #fff; }
.order-item-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.order-item-header h3 { margin: 0; font-size: 16px; }
.remove-item { color: var(--danger); background: white; border: 1px solid #f3bdc4; border-radius: 8px; padding: 6px 8px; font-size: 12px; font-weight: 800; }
.item-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 13px; padding: 12px; border-radius: 9px; background: #fafbfe; color: var(--muted); font-size: 13px; }
.item-summary strong { color: var(--ink); display: block; font-size: 20px; margin-top: 3px; }
.size-grid { display: grid; grid-template-columns: repeat(7, minmax(75px, 1fr)); gap: 10px; margin-top: 15px; }
.size-grid .field input { text-align: center; }
.image-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; margin-top: 12px; }
.image-preview { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fafbfe; }
.image-preview img { width: 100%; height: 130px; object-fit: cover; display: block; }
.image-preview label { display: flex; gap: 7px; padding: 8px; font-size: 12px; align-items: center; color: #49536a; }
.order-detail-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.meta-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 17px 0; }
.meta-list div { background: #fafbfe; border: 1px solid var(--line); border-radius: 10px; padding: 11px; }
.meta-list span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.meta-list strong { display: block; margin-top: 3px; }
.mini-log { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.mini-log li { display: grid; grid-template-columns: 145px 1fr; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); color: #4e5870; font-size: 14px; }
.mini-log li:last-child { padding-bottom: 0; border-bottom: none; }
.mini-log time { color: var(--muted); font-size: 13px; }
.no-results { padding: 22px; text-align: center; color: var(--muted); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 20px; }
.badge-note { color: #6743bf; background: var(--accent-soft); border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; }

@media (max-width: 960px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { overflow-x: auto; padding: 9px 12px; border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; width: max-content; gap: 5px; }
  .sidebar a { white-space: nowrap; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.triple { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .size-grid { grid-template-columns: repeat(5, minmax(75px, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .public-header { min-height: 68px; padding: 10px 16px; }
  .brand { gap: 8px; }
  .brand img { width: 42px; height: 34px; }
  .brand span { font-size: 15px; }
  .admin-link { padding: 7px 9px; font-size: 12px; }
  .public-main, .public-detail { width: min(100% - 24px, 1600px); margin-top: 18px; }
  .screen-intro { display: block; }
  .refresh-note { margin-top: 8px; white-space: normal; }
  .order-grid { grid-template-columns: 1fr; }
  .card-head, .detail-head { padding: 18px; display: block; }
  .card-head .status, .detail-head .status { margin-top: 12px; }
  .card-body, .detail-body { padding: 16px; }
  .admin-header { padding: 8px 14px; }
  .admin-brand span { display: none; }
  .user-menu { gap: 9px; }
  .admin-content { padding: 20px 14px 40px; }
  .page-title { align-items: flex-start; flex-direction: column; }
  .kpi-grid, .form-grid, .form-grid.triple, .meta-list { grid-template-columns: 1fr; }
  .size-grid { grid-template-columns: repeat(3, minmax(75px, 1fr)); }
  .item-summary { grid-template-columns: 1fr; }
  .mini-log li { grid-template-columns: 1fr; gap: 4px; }
}
