/* Quản trị Landfoods — phong cách WinForms: thanh tiêu đề, sider trái, lưới dữ liệu, thanh trạng thái.
   Mọi ô nhập luôn ≥ 16px (Safari iOS không tự phóng to). */
:root {
  --surface: #f0f0f0; --panel: #fff; --border: #a9a9a9; --border-l: #d6d6d6; --text: #1b1b1b; --muted: #666;
  --accent: #0078d7; --accent-h: #e5f1fb; --accent-d: #cce4f7; --danger: #c42b1c; --ok: #107c10; --warn: #8a5a00;
  --brand: #2d1d0e; --gold: #e2ad67;
  --sans: "Segoe UI", Tahoma, "Helvetica Neue", Arial, sans-serif;
  --title-h: 44px; --status-h: 28px; --sider-w: 236px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface); color: var(--text); font: 400 14px/1.4 var(--sans); overflow: hidden; }
h1, h2, h3, p, ul, ol, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { font-size: 16px; }
img, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); }
svg { flex: none; }
.nojs { padding: 24px; }
#app { height: 100dvh; display: flex; flex-direction: column; }

/* ───────── nút (kiểu Button của WinForms) ───────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 0 16px; border: 1px solid var(--border); border-radius: 2px; background: #e1e1e1; color: var(--text);
  font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.btn:hover:not(:disabled) { background: var(--accent-h); border-color: var(--accent); }
.btn:active:not(:disabled) { background: var(--accent-d); }
.btn:disabled { color: #8a8a8a; background: #f2f2f2; border-color: #cfcfcf; cursor: default; }
.btn:focus-visible, .nav-item:focus-visible, .th-btn:focus-visible, .x:focus-visible, .tb-btn:focus-visible { outline: 2px dotted #000; outline-offset: -4px; }
.btn-default { border: 2px solid var(--accent); padding: 0 15px; }
.btn-danger { color: var(--danger); }
.btn-sm { min-height: 28px; padding: 0 12px; }
.btn-block { width: 100%; }
.file { position: relative; overflow: hidden; }
.file input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

/* ───────── thanh tiêu đề ───────── */
.titlebar { flex: none; height: var(--title-h); display: flex; align-items: center; gap: 10px; padding: 0 8px 0 12px; background: var(--brand); color: #fff; border-bottom: 1px solid #000; user-select: none; }
.titlebar .app-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 3px; background: var(--gold); color: var(--brand); font-weight: 800; font-size: 14px; }
.titlebar h1 { flex: 1; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titlebar h1 small { font-weight: 400; color: #d9c7a5; }
.tb-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border: 1px solid transparent; border-radius: 2px; background: transparent; color: #fff; font-size: 13px; text-decoration: none; cursor: pointer; }
.tb-btn:hover { background: rgb(255 255 255 / .16); border-color: rgb(255 255 255 / .3); }
.tb-btn:focus-visible { outline-color: #fff; }
.menu-btn { display: none; padding: 0 8px; }

/* ───────── khung: sider + nội dung ───────── */
.shell { flex: 1; min-height: 0; display: flex; position: relative; }
.sider { flex: none; width: var(--sider-w); display: flex; flex-direction: column; background: #f7f7f7; border-right: 1px solid var(--border); }
.sider-head { padding: 12px 14px 6px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav { display: flex; flex-direction: column; padding: 2px 6px; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: 2px; background: transparent; text-align: left; cursor: pointer; font-size: 14px; }
.nav-item svg { width: 18px; height: 18px; color: #555; }
.nav-item:hover { background: var(--accent-h); border-color: #b9d9f3; }
.nav-item[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.nav-item[aria-current="page"] svg { color: #fff; }
.nav-item .badge { margin-left: auto; min-width: 26px; padding: 1px 7px; border-radius: 10px; background: #dcdcdc; color: #333; font-size: 12px; text-align: center; }
.nav-item[aria-current="page"] .badge { background: rgb(255 255 255 / .25); color: #fff; }
.sider-foot { margin-top: auto; padding: 10px 14px; border-top: 1px solid var(--border-l); font-size: 12px; color: var(--muted); }
.sider-foot b { color: var(--text); font-weight: 600; }
.scrim { display: none; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.page-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--border-l); }
.page-head svg { width: 22px; height: 22px; color: var(--accent); }
.page-head h2 { font-size: 18px; font-weight: 600; }
.page-head p { margin-left: 6px; color: var(--muted); font-size: 13px; }
.view { flex: 1; min-height: 0; overflow: auto; padding: 14px; }
.view.fill { display: flex; flex-direction: column; overflow: hidden; padding: 0; }

.statusbar { flex: none; height: var(--status-h); display: flex; align-items: center; gap: 0; background: #f0f0f0; border-top: 1px solid var(--border); font-size: 12px; user-select: none; }
.statusbar > span { padding: 0 12px; height: 100%; display: flex; align-items: center; border-right: 1px solid #cfcfcf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.statusbar > span:first-child { flex: 1; min-width: 0; }
.statusbar > span:last-child { border-right: 0; }
.statusbar .err { color: var(--danger); font-weight: 600; }
.statusbar .okc { color: var(--ok); }

/* ───────── hộp nhóm, bảng điều khiển ───────── */
.group { margin: 0 0 14px; padding: 10px 14px 14px; border: 1px solid var(--border-l); background: var(--panel); min-width: 0; }
.group > legend { padding: 0 6px; font-weight: 600; color: #0a4f8a; }
.panel { background: var(--panel); border: 1px solid var(--border-l); min-width: 0; }
.panel > h3 { padding: 7px 12px; border-bottom: 1px solid var(--border-l); background: linear-gradient(#fafafa, #ececec); font-size: 13px; font-weight: 600; }
.panel .pb { padding: 12px; }
.dash { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.span2 { grid-column: span 2; }
.span4 { grid-column: 1 / -1; }
.kpi { padding: 12px 14px; background: var(--panel); border: 1px solid var(--border-l); border-left: 4px solid var(--accent); }
.kpi span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; margin-top: 2px; font-size: 24px; font-weight: 600; line-height: 1.2; }
.kpi small { color: var(--muted); }
.kpi.gold { border-left-color: var(--gold); } .kpi.green { border-left-color: var(--ok); } .kpi.red { border-left-color: #e0452d; }
table.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
table.plain th, table.plain td { padding: 6px 10px; border-bottom: 1px solid #ececec; text-align: left; }
table.plain th { background: #f6f6f6; font-weight: 600; }
table.plain td.r, table.plain th.r { text-align: right; }
.cover-sum { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: start; }
.cover-sum img { width: 96px; height: 120px; object-fit: cover; border: 1px solid var(--border-l); background: #111; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }
.feed li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid #efefef; font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed time { flex: none; width: 96px; color: var(--muted); }
.msg { margin: 0 0 12px; padding: 8px 12px; border: 1px solid; font-size: 13px; }
.msg.err { background: #fde7e9; border-color: #f1b5ba; color: #8a1c1c; }
.msg.ok { background: #e7f4e7; border-color: #b4d9b4; color: #0b5a0b; }
.hint { font-size: 12.5px; color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ───────── thanh công cụ + lưới dữ liệu (DataGridView) ───────── */
.toolstrip { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; background: linear-gradient(#fcfcfc, #e9e9e9); border-bottom: 1px solid var(--border); }
.toolstrip .sep { width: 1px; align-self: stretch; margin: 2px 4px; background: #c4c4c4; }
.toolstrip label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.toolstrip select, .toolstrip input[type="search"] { min-height: 32px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 2px; background: #fff; }
.toolstrip input[type="search"] { width: min(280px, 46vw); }
.toolstrip .grow { flex: 1; }
.grid-wrap { flex: 1; min-height: 0; overflow: auto; background: #fff; outline: 0; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; table-layout: fixed; }
table.grid thead th { position: sticky; top: 0; z-index: 2; padding: 0; border-right: 1px solid #cfcfcf; border-bottom: 1px solid var(--border); background: linear-gradient(#fdfdfd, #e6e6e6); text-align: left; font-weight: 600; }
.th-btn { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-height: 34px; padding: 0 10px; border: 0; background: transparent; font-weight: 600; cursor: pointer; text-align: left; }
.th-btn:hover { background: rgb(0 120 215 / .1); }
.th-btn .gl { color: #555; font-size: 10px; }
th.num .th-btn, th.price .th-btn { justify-content: flex-end; }
table.grid tbody td { padding: 5px 10px; border-right: 1px solid #ececec; border-bottom: 1px solid #ececec; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid tbody tr:nth-child(even) td { background: #f8f8f8; }
table.grid tbody tr:hover td { background: var(--accent-h); }
table.grid tbody tr[aria-selected="true"] td { background: var(--accent); color: #fff; border-color: #2a8be0; }
table.grid tbody tr[aria-selected="true"] td .sub { color: #dbeaff; }
.c-img { width: 72px; } .c-num { width: 64px; text-align: right; } .c-price { width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
.c-name { width: 24%; } .c-tier { width: 120px; } .c-benefit { width: 28%; }
.c-img img { width: 56px; height: 47px; object-fit: cover; border: 1px solid #ccc; background: #ddd; }
table.grid tbody tr[aria-selected="true"] .c-img img { border-color: #fff; }
td.c-name b { font-weight: 600; }
.grid-empty { padding: 36px; text-align: center; color: var(--muted); }

/* ───────── cửa sổ (dialog) kiểu Form ───────── */
dialog.win { width: min(900px, calc(100% - 24px)); max-width: 100%; max-height: calc(100dvh - 24px); margin: auto; padding: 0; border: 1px solid #1f1f1f; border-radius: 0; background: var(--surface); color: var(--text);
  box-shadow: 0 8px 40px rgb(0 0 0 / .5); overflow: hidden; }
dialog.win[open] { display: flex; flex-direction: column; }
dialog.win::backdrop { background: rgb(0 0 0 / .45); }
body:has(dialog[open]) { overflow: hidden; }
.win-title { flex: none; display: flex; align-items: center; gap: 8px; height: 36px; padding-left: 10px; background: var(--brand); color: #fff; user-select: none; }
.win-title .app-icon { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 2px; background: var(--gold); color: var(--brand); font-weight: 800; font-size: 11px; }
.win-title h2 { flex: 1; font-size: 14px; font-weight: 600; }
.x { width: 46px; height: 36px; border: 0; background: transparent; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.x:hover { background: #e81123; }
.win-body { flex: 1; min-height: 0; overflow: auto; padding: 14px; }
.win-buttons { flex: none; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 10px 14px; background: #f0f0f0; border-top: 1px solid #c8c8c8; }
.editor { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.photo { position: relative; border: 1px solid var(--border); background: #111; aspect-ratio: 592 / 500; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / .55); color: #fff; font-weight: 600; }

/* ───────── biểu mẫu ───────── */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 13px; font-weight: 600; }
.field small { font-weight: 400; color: var(--muted); }
.field input, .field textarea, .field select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 2px; background: #fff; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.radios { display: grid; gap: 4px; }
.radios label { display: flex; align-items: center; gap: 8px; min-height: 30px; cursor: pointer; }
.radios input { width: 16px; height: 16px; accent-color: var(--accent); }
.media-box { margin: 10px 0; border: 1px solid var(--border); background: #111; }
.media-box video { width: 100%; max-height: 52dvh; margin: 0 auto; background: #111; }
.media-box img { max-height: 52dvh; margin: 0 auto; }
.meta { margin: 6px 0 10px; font-size: 13px; color: var(--muted); }
.bar { height: 16px; margin: 8px 0; border: 1px solid var(--border); background: #e6e6e6; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: #06b025; transition: width .2s; }
.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }

/* ───────── cửa sổ đăng nhập ───────── */
.auth { height: 100dvh; display: grid; place-items: center; padding: 14px; overflow: auto; background: radial-gradient(ellipse at 50% 30%, #4a3320, #1c1209); }
.auth-win { width: min(420px, 100%); border: 1px solid #000; background: var(--surface); box-shadow: 0 10px 50px rgb(0 0 0 / .6); }
.auth-win .win-body { padding: 18px; }
.auth-win h1 { margin-bottom: 4px; font-size: 18px; font-weight: 600; }
.auth-win .sub { margin-bottom: 16px; color: var(--muted); font-size: 13px; }

/* ───────── thông báo nổi ───────── */
#toast { position: fixed; z-index: 60; right: 16px; bottom: calc(var(--status-h) + 14px); max-width: min(92vw, 420px); padding: 10px 14px; border: 1px solid #1f1f1f; border-left: 4px solid var(--ok); background: #fff; color: var(--text);
  box-shadow: 0 4px 18px rgb(0 0 0 / .3); font-size: 13.5px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s, transform .18s; }
#toast.show { opacity: 1; transform: none; }
#toast.bad { border-left-color: var(--danger); }

/* ───────── máy tính hẹp / điện thoại ───────── */
@media (max-width: 1100px) { .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span4 { grid-column: 1 / -1; } .cols2 { grid-template-columns: 1fr; } .hide-md { display: none; } .c-name { width: auto; } }
@media (max-width: 899px) {
  .menu-btn { display: inline-flex; }
  .sider { position: fixed; z-index: 40; left: 0; top: var(--title-h); bottom: var(--status-h); transform: translateX(-102%); transition: transform .2s; box-shadow: 4px 0 18px rgb(0 0 0 / .3); }
  .sider.open { transform: none; }
  .scrim { position: fixed; inset: var(--title-h) 0 var(--status-h) 0; z-index: 35; background: rgb(0 0 0 / .35); }
  .sider.open + .scrim, .scrim.on { display: block; }
  .page-head p { display: none; }
  .titlebar .tb-btn span { display: none; }
  .titlebar h1 small { display: none; }
}
@media (max-width: 720px) {
  .view { padding: 10px; }
  .dash { grid-template-columns: 1fr 1fr; gap: 8px; }
  .span2 { grid-column: 1 / -1; }
  .kpi b { font-size: 19px; }
  .hide-sm { display: none; }
  .c-img { width: 62px; } .c-num { width: 46px; } .c-price { width: 108px; }
  .toolstrip { padding: 6px 8px; }
  .toolstrip input[type="search"] { width: 100%; flex: 1; }
  .editor { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  dialog.win { width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; }
  .statusbar .st-mid { display: none; }
  .cover-sum { grid-template-columns: 72px 1fr; }
  .cover-sum img { width: 72px; height: 90px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* bổ sung */
.toolstrip .grow { text-align: right; }
.grid-wrap:focus-visible { outline: 2px dotted #000; outline-offset: -3px; }
.cover-sum .acts { margin-top: 10px; }
.editor .group .hint { margin: 8px 0; }
.group .hint { margin-bottom: 8px; }

@media (max-width: 720px) {
  .toolstrip { gap: 6px; }
  .toolstrip .sep { display: none; }
  .toolstrip label { flex: 1 1 auto; }
  .toolstrip label select { flex: 1; min-width: 0; }
  .toolstrip input[type="search"] { order: 9; flex: 1 1 100%; width: 100%; }
  .toolstrip .grow { order: 10; flex: 1 1 100%; text-align: left; }
}

/* đơn hàng */
.c-code { width: 130px; } .c-time { width: 130px; } .c-phone { width: 124px; } .c-total { width: 132px; text-align: right; font-variant-numeric: tabular-nums; } .c-st { width: 118px; }
.c-cust { width: 18%; }
th.c-total .th-btn { justify-content: flex-end; }
.pill { display: inline-block; padding: 1px 9px; border: 1px solid; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-new { background: #fde7e9; border-color: #f1b5ba; color: #a4262c; }
.st-contacted { background: #fff4ce; border-color: #f2d77a; color: #7a5800; }
.st-shipping { background: #e0f0ff; border-color: #a9d3f5; color: #0b5394; }
.st-done { background: #e7f4e7; border-color: #b4d9b4; color: #0b5a0b; }
.st-cancelled { background: #eee; border-color: #ccc; color: #666; }
.nav-item .badge.hot { background: #e81123; color: #fff; }
.nav-item[aria-current="page"] .badge.hot { background: #fff; color: #c50f1f; }
table.plain tfoot th { background: #f6f6f6; border-top: 2px solid #cfcfcf; }
.od { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.win-buttons .del { margin-right: auto; }
.feed li > span:not(.pill) { flex: 1; min-width: 0; }
.feed li .pill { flex: none; align-self: center; }
.group .kv dd a { margin-right: 2px; }
@media (max-width: 1100px) { .od { grid-template-columns: 1fr; } }

/* cổng đại lý / quản lý đại lý */
.linkrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.linkrow input { flex: 1; min-width: 220px; min-height: 36px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 2px; background: #fff; }
.c-addr { width: 26%; } .c-num2 { width: 90px; text-align: right; }
th.c-num2 .th-btn { justify-content: flex-end; }
.c-user { width: 150px; } .c-st2 { width: 120px; }
.pill.st-on { background: #e7f4e7; border-color: #b4d9b4; color: #0b5a0b; }
.pill.st-off { background: #eee; border-color: #ccc; color: #666; }
.give { margin: 10px 0 0; padding: 10px 12px; border: 1px dashed #8a6d2b; background: #fffbea; }
.give pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.5 Consolas, "Courier New", monospace; user-select: all; }
.inline-btns { display: flex; gap: 8px; }
.inline-btns input { flex: 1; min-width: 0; }
