:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2633;
  background: #edf1f7;
  font-size: 14px;
  color-scheme: light;
  --ink: #1f2633;
  --muted: #7a8495;
  --app-bg: #edf1f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #e7ebf2;
  --line-strong: #d8deea;
  --accent: #17b8d4;
  --accent-dark: #0c8faa;
  --accent-soft: #e7f9fc;
  --blue: #4f8cff;
  --pink: #ef4c9a;
  --purple: #8b6cff;
  --orange: #ff8a3d;
  --green: #16c79a;
  --yellow: #f6c143;
  --danger: #ef4444;
  --danger-soft: #fff0f0;
  --shadow-sm: 0 10px 28px rgb(25 36 55 / .07);
  --shadow-lg: 0 24px 80px rgb(25 36 55 / .14);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--app-bg); }
body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -10%, rgb(255 255 255 / .9) 0 230px, transparent 231px),
    radial-gradient(circle at 95% 10%, rgb(23 184 212 / .12) 0 260px, transparent 261px),
    linear-gradient(135deg, #f7f9fd 0%, #e8edf5 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgb(255 255 255 / .8) 0 3px, transparent 4px),
    radial-gradient(circle, rgb(255 255 255 / .45) 0 2px, transparent 3px);
  background-size: 96px 96px, 142px 142px;
  opacity: .55;
}

button, input, textarea, select { font: inherit; }
button {
  min-height: 40px;
  border: 0;
  border-radius: 13px;
  padding: 10px 16px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 850;
  box-shadow: 0 10px 22px rgb(23 184 212 / .22);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
button:hover { background: var(--accent-dark); box-shadow: 0 12px 26px rgb(12 143 170 / .24); }
button:active { transform: translateY(1px); }
button.secondary {
  color: #4f5b6f;
  background: #f5f8fc;
  border: 1px solid var(--line);
  box-shadow: none;
}
button.secondary:hover { color: var(--accent-dark); background: var(--accent-soft); }
button.danger, button.secondary.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #ffd3d3;
  box-shadow: none;
}
button.danger:hover, button.secondary.danger:hover { color: #ffffff; background: var(--danger); }
button.icon {
  width: 38px;
  min-height: 38px;
  padding: 0;
  color: #5d687b;
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: none;
  font-size: 20px;
}
button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

main {
  position: relative;
  z-index: 1;
  width: min(100%, 1360px);
  margin: 0 auto;
  padding: 34px;
}
.hidden { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; color: var(--ink); font-size: 20px; line-height: 1.1; letter-spacing: -.03em; }
h2 { margin-bottom: 6px; color: var(--ink); font-size: 18px; line-height: 1.22; letter-spacing: -.02em; }
p { color: var(--muted); line-height: 1.58; }
code {
  padding: 2px 6px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 8px;
}

label { display: grid; gap: 8px; color: #465063; font-size: 12px; font-weight: 800; }
input, textarea, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fbfcff;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea { line-height: 1.55; resize: vertical; }
input:hover, textarea:hover, select:hover { border-color: var(--line-strong); }
input:focus, textarea:focus, select:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgb(23 184 212 / .13);
  background: #ffffff;
}
.error { min-height: 18px; margin: 8px 0 0; color: var(--danger); }
.form-error { margin: 0; font-size: 11px; }

.panel,
.login-panel,
.tab-content,
.dashboard-block,
.data-card,
dialog {
  background: rgb(255 255 255 / .9);
  border: 1px solid rgb(255 255 255 / .72);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}

.login {
  min-height: calc(100vh - 84px);
  display: grid;
  place-items: center;
}
.login-panel {
  width: min(430px, 100%);
  padding: 32px;
}
.login-panel > p { margin: 18px 0 22px; }
.login-panel button { width: 100%; margin-top: 16px; }

#dashboard-view {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
  grid-template-areas:
    "side top"
    "side content";
  gap: 18px;
  min-height: calc(100vh - 84px);
  padding: 14px;
  background: rgb(255 255 255 / .56);
  border: 1px solid rgb(255 255 255 / .78);
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px);
}
#dashboard-view.hidden { display: none !important; }

header {
  grid-area: top;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 8px 14px;
  background: rgb(255 255 255 / .86);
  border: 1px solid rgb(255 255 255 / .76);
  border-radius: 22px;
  box-shadow: 0 12px 32px rgb(25 36 55 / .06);
}
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--accent);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 950;
  box-shadow: 0 10px 20px rgb(23 184 212 / .25);
}
.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: #9aa4b5;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.system-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 12px;
  color: #4c586c;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}
.system-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(23 184 212 / .13);
}

.tabs {
  grid-area: side;
  position: sticky;
  top: 14px;
  align-self: start;
  min-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 18px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 16px 44px rgb(25 36 55 / .07);
}
.tabs::before {
  content: "";
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 10px 18px;
  background: var(--accent);
  border-radius: 11px;
  box-shadow: 0 10px 22px rgb(23 184 212 / .22);
}
.tabs button {
  width: 100%;
  justify-content: flex-start;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 10px;
  color: #7a8495;
  background: transparent;
  border: 0;
  border-radius: 13px;
  box-shadow: none;
  font-size: 12px;
}
.tabs button::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  background: currentColor;
  border-radius: 50%;
  opacity: .55;
}
.tabs button:hover,
.tabs button.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgb(23 184 212 / .22);
}
.mobile-tab-picker { display: none; }
.mobile-app-nav { display: none; }

.tab-content {
  grid-area: content;
  min-width: 0;
  padding: 20px;
  animation: reveal .18s ease;
}
@keyframes reveal { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.section-title h2 { font-size: 20px; }
.section-title p { margin-bottom: 0; font-size: 12px; }
.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.section-actions button { min-height: 38px; padding: 9px 13px; font-size: 12px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.dashboard-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 98px;
  padding: 16px 76px 16px 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}
.stat::before { content: none; }
.stat-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 6px solid #ffffff;
  border-radius: 16px;
  background: var(--accent);
  box-shadow: 0 12px 22px rgb(25 36 55 / .12);
}
.stat-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stat-waiting .stat-icon { background: var(--green); }
.stat-revenue .stat-icon { background: var(--blue); }
.stat-products .stat-icon { background: var(--orange); }
.stat-stock .stat-icon { background: var(--pink); }
.stat-users .stat-icon { background: var(--purple); }
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  line-height: 1.25;
}
.stat strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 23px;
  line-height: 1.04;
  overflow-wrap: anywhere;
}
.dashboard-stats .stat:nth-child(3) strong {
  font-size: clamp(18px, 1.5vw, 22px);
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr);
  gap: 16px;
}
.dashboard-block {
  min-width: 0;
  padding: 16px;
}
.dashboard-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.dashboard-block-head h2 { margin: 0; font-size: 15px; }
.dashboard-block-head button { min-height: 34px; padding: 7px 10px; font-size: 11px; }
.dashboard-list {
  display: grid;
  gap: 9px;
  max-height: min(50vh, 440px);
  overflow-y: auto;
  padding-right: 3px;
}
.dashboard-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.dashboard-row-main { min-width: 0; display: grid; gap: 3px; }
.dashboard-row-main strong, .dashboard-row-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-row-main strong { font-size: 12px; }
.dashboard-row-main span, .dashboard-row-main small { color: var(--muted); font-size: 10px; }
.dashboard-row-value { flex: 0 0 auto; display: grid; justify-items: end; gap: 5px; }
.stock-summary { min-width: 58px; flex: 0 0 auto; display: grid; justify-items: end; gap: 2px; }
.stock-summary strong { color: var(--accent-dark); font-size: 18px; line-height: 1; }
.stock-summary span { color: var(--muted); font-size: 8px; font-weight: 900; text-transform: uppercase; }
.stock-summary.low strong { color: #b77900; }
.stock-summary.out strong { color: var(--danger); }

.order-status-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin: -4px 0 16px;
}
.order-status-tabs button {
  min-width: 0;
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  color: #536075;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  box-shadow: none;
  text-align: left;
}
.order-status-tabs button:hover,
.order-status-tabs button.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}
.order-status-tabs span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.18;
}
.order-status-tabs strong {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.order-status-tabs button.active strong,
.order-status-tabs button:hover strong { color: var(--accent-dark); background: #ffffff; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-height: min(72vh, 780px);
  overflow-y: auto;
  align-content: start;
  padding: 2px 6px 8px 2px;
  scrollbar-gutter: stable;
}
.products-grid, .users-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid::-webkit-scrollbar, .stock-files-list::-webkit-scrollbar, .dashboard-list::-webkit-scrollbar { width: 7px; }
.card-grid::-webkit-scrollbar-thumb, .stock-files-list::-webkit-scrollbar-thumb, .dashboard-list::-webkit-scrollbar-thumb { background: #c7cfdb; border-radius: 999px; }
.card-grid::-webkit-scrollbar-track, .stock-files-list::-webkit-scrollbar-track, .dashboard-list::-webkit-scrollbar-track { background: #edf1f7; border-radius: 999px; }

.data-card {
  min-width: 0;
  display: grid;
  gap: 11px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.data-card:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgb(25 36 55 / .11); border-color: var(--line-strong); }
.order-card { border-top: 4px solid var(--accent); }
.order-card-unpaid { border-top-color: var(--yellow); }
.order-card-confirming { border-top-color: var(--blue); }
.order-card-paid { border-top-color: var(--green); }
.order-card-cancelled { border-top-color: var(--danger); }
.product-card { border-top: 4px solid var(--orange); }
.user-card { border-top: 4px solid var(--blue); }
.announcement-card { border-top: 4px solid var(--purple); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-heading > div { min-width: 0; }
.card-heading strong { display: block; overflow-wrap: anywhere; font-size: 15px; line-height: 1.35; }
.card-kicker { display: block; margin-bottom: 4px; color: #9aa4b5; font-size: 8px; font-weight: 950; text-transform: uppercase; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.card-meta span, .availability {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 9px;
  color: #6b7588;
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
}
.availability.active { color: #067f68; background: #e8fbf6; border-color: #bcf2e6; }
.card-section {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}
.card-section > span, .product-numbers span, .user-details span {
  color: #9aa4b5;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}
.card-section strong { overflow-wrap: anywhere; }
.card-section small { color: var(--muted); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }
.item-list { display: grid; gap: 7px; }
.order-card .item-list { max-height: 86px; overflow-y: auto; padding-right: 3px; }
.item-list div { display: flex; justify-content: space-between; gap: 10px; }
.item-list b { color: var(--accent-dark); white-space: nowrap; }

.product-image-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.product-image-strip figure {
  position: relative;
  min-width: 0;
  aspect-ratio: 1 / 1;
  margin: 0;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.product-image-strip img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 5px;
  background: #ffffff;
}
.product-image-strip button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  min-height: 24px;
  padding: 0;
  color: #ffffff;
  background: rgb(239 68 68 / .92);
  border-radius: 999px;
  box-shadow: none;
  font-size: 12px;
}
.product-image-empty {
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  font-size: 11px;
  font-weight: 800;
}
.product-image-more {
  min-height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  font-size: 11px;
  font-weight: 900;
}
.product-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.product-summary span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  color: #4f5b6f;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
}
.product-summary b {
  color: #9aa4b5;
  font-size: 9px;
  text-transform: uppercase;
}
.product-numbers, .user-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.product-numbers div, .user-details div {
  min-width: 0;
  padding: 9px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.product-numbers span, .product-numbers strong, .user-details span, .user-details strong { display: block; }
.product-numbers strong, .user-details strong { margin-top: 3px; font-size: 14px; overflow-wrap: anywhere; }
.empty-state {
  grid-column: 1 / -1;
  padding: 34px;
  color: var(--muted);
  background: #ffffff;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  text-align: center;
}
.empty-state.compact { padding: 20px; }
.actions, .banner-actions, .notification-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button { min-height: 32px; padding: 7px 9px; font-size: 10px; }
.product-card {
  position: relative;
  padding-right: 42px;
}
.product-card .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.product-card .actions button {
  width: auto;
  min-width: 0;
  flex: 1 1 112px;
}
.product-delete-x {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 30px;
  min-height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #ffd3d3;
  border-radius: 999px;
  box-shadow: none;
  font-size: 18px;
  font-weight: 950;
  line-height: 1;
}
.product-delete-x:hover {
  color: #ffffff;
  background: var(--danger);
}
.reorder-pick {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 30px;
  min-height: 30px;
  padding: 0;
  color: var(--accent-dark);
  background: #ffffff;
  border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgb(25 36 55 / .12);
}
.reorder-pick.active {
  color: #ffffff;
  background: var(--accent);
}
.reorder-handle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #ffffff;
  background: var(--accent);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 950;
  box-shadow: 0 8px 18px rgb(23 184 212 / .2);
}
.product-card.is-reordering {
  cursor: grab;
  padding-top: 46px;
  border-color: #bdeff7;
}
.product-card.is-reordering .product-actions {
  display: none;
}
.product-card.selected {
  border-color: var(--accent);
  box-shadow: 0 18px 42px rgb(23 184 212 / .16);
}
.product-card.dragging {
  opacity: .62;
  cursor: grabbing;
}
.product-card.drop-target {
  outline: 3px dashed var(--accent);
  outline-offset: 4px;
}
.reorder-active {
  user-select: none;
}
#product-reorder-hint.compact {
  margin: -6px 0 14px;
  padding: 10px 12px;
  font-size: 12px;
}
/* legacy product numbers kept for old cards; new cards use product-summary. */
.product-card .product-numbers {
  display: none;
}
/* override older grid rule for compact product actions */
.product-card .actions {
  grid-template-columns: none;
  gap: 7px;
}

.status {
  min-height: 30px;
  padding: 6px 9px;
  color: #5d687a;
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 850;
}
.status.paid { color: #05765f; background: #e8fbf6; border-color: #bcf2e6; }
.status.waiting { color: #9a6500; background: #fff7df; border-color: #ffe4a6; }
.status.cancelled { color: var(--danger); background: var(--danger-soft); border-color: #ffd3d3; }

.tool-row {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 1fr auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.tool-row span { color: var(--muted); padding-bottom: 11px; font-size: 12px; }
.form-panel { max-width: 760px; padding: 18px; display: grid; gap: 14px; }
.status-box {
  padding: 13px;
  color: #4f5b6f;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-left: 4px solid #9aa4b5;
  border-radius: 16px;
}
.status-box.ready { color: #067f68; background: #e8fbf6; border-color: #bcf2e6; border-left-color: var(--green); }
.note { margin: 0; font-size: 11px; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.history-title { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.announcement-text { margin: 0; color: #3d4657; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; max-height: 104px; overflow-y: auto; font-size: 12px; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.emoji-picker .emoji-option {
  width: 34px;
  min-height: 34px;
  padding: 2px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: none;
  font-size: 16px;
  line-height: 1;
}
.announcement-image-preview, .announcement-card-image, .banner-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 15px;
}
.announcement-card { gap: 9px; }
#broadcast-tab #broadcast-form {
  max-width: none;
  grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr);
  align-items: start;
}
#broadcast-tab #broadcast-form > .broadcast-side {
  grid-column: 1;
}
#broadcast-tab #broadcast-form > .broadcast-main {
  grid-column: 2;
}
#broadcast-tab textarea { min-height: 150px; }

.bot-settings-title { margin-bottom: 14px; }
.bot-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}
#bot-settings-tab .form-panel { max-width: none; padding: 18px; gap: 14px; }
#banner-form { grid-column: 1; grid-row: 1; }
#welcome-form { grid-column: 2; grid-row: 1; }
#notification-target-form { grid-column: 1; grid-row: 2; }
#password-form { grid-column: 2; grid-row: 2; }
.setting-card-head { display: grid; gap: 4px; }
.setting-card-head h2 { margin: 0; font-size: 15px; }
.setting-card-head p { max-width: 720px; margin: 0; font-size: 12px; line-height: 1.45; }
.landing-image-form, .landing-form { max-width: none; }
.landing-maintenance-panel,
.landing-image-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.landing-maintenance-panel .setting-card-head,
.landing-image-form .setting-card-head,
.landing-image-form label,
.landing-image-form .status-box,
.landing-image-form .banner-preview,
.landing-image-form .note { grid-column: 1; }
.landing-maintenance-panel .status-box,
.landing-maintenance-panel .banner-actions,
.landing-image-form .banner-actions,
.landing-image-form .form-footer { grid-column: 2; }
.landing-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
.landing-form > .status-box,
.landing-form > .form-footer { grid-column: 1 / -1; }
.landing-form > .split,
.landing-form > label { min-width: 0; }
.landing-form > .landing-fieldset { min-width: 0; }
.landing-fieldset {
  display: grid;
  gap: 10px;
  padding: 13px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.landing-fieldset h3 { margin: 0; color: var(--accent-dark); font-size: 14px; }
.landing-form textarea { min-height: 64px; }
.landing-form .split { gap: 10px; }
#welcome-message { min-height: 185px; }
#bot-settings-tab .status-box { padding: 11px 12px; font-size: 12px; }
#bot-settings-tab input, #bot-settings-tab textarea { padding: 10px 12px; }

dialog {
  width: min(560px, calc(100% - 24px));
  padding: 0;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgb(31 38 51 / .48); backdrop-filter: blur(8px); }
dialog form, .stock-dialog-content { display: grid; gap: 15px; padding: 22px; }
.confirm-dialog-content { display: grid; gap: 15px; padding: 22px; }
.confirm-dialog-content p { margin: 0; }
.product-dialog-images {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.product-dialog-images p { margin: 0; font-size: 11px; }
.product-dialog-image-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
  padding-right: 2px;
}
.product-dialog-image-list figure {
  position: relative;
  aspect-ratio: 1 / 1;
  margin: 0;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 13px;
}
.product-dialog-image-list img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 5px;
  background: #ffffff;
}
.dialog-image-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  min-height: 24px;
  padding: 0;
  color: #ffffff;
  background: rgb(239 68 68 / .94);
  border-radius: 999px;
  box-shadow: none;
  font-size: 14px;
  line-height: 1;
}
.stock-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.stock-files-list { display: grid; gap: 8px; max-height: min(52vh, 500px); overflow-y: auto; padding-right: 3px; }
.stock-file-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 11px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
}
.stock-file-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.stock-file-row input { width: auto; }
.stock-file-row span, .stock-file-row strong, .stock-file-row small { display: block; min-width: 0; }
.stock-file-row strong { overflow-wrap: anywhere; font-size: 12px; }
.stock-file-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-head { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
.dialog-actions { justify-content: flex-end; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100% - 32px));
  padding: 12px 14px;
  color: #ffffff;
  background: #1f2633;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* Final layout polish: stable spacing across every admin tab. */
#dashboard-view {
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 20px;
}

.tabs {
  gap: 9px;
  padding: 18px 12px;
}

.tabs button {
  min-height: 42px;
  gap: 6px;
  padding-inline: 8px;
  text-align: left;
  white-space: normal;
  line-height: 1.2;
}

.tabs button::before {
  width: 5px;
  height: 5px;
  flex-basis: 5px;
}

header {
  padding-inline: 16px;
}

.tab-content {
  display: block;
  padding: 22px;
}

.section-title {
  align-items: center;
  margin-bottom: 22px;
}

.section-title > div {
  min-width: 0;
}

.section-title p {
  max-width: 680px;
}

.stats {
  padding-top: 18px;
}

.dashboard-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#orders-body {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#products-body {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#products-tab {
  width: 100%;
  max-width: 1120px;
  margin-inline: 0 auto;
}

#products-tab .section-title,
#products-tab #product-reorder-hint,
#products-tab #products-body {
  width: 100%;
}

#products-tab .section-title {
  align-items: flex-start;
}

#products-tab #products-body {
  margin-inline: auto;
  padding-inline: 0 4px;
  justify-content: stretch;
}

#announcements-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: min(52vh, 560px);
}

#users-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.data-card {
  align-content: start;
}

.card-heading {
  min-width: 0;
  align-items: flex-start;
}

.card-heading .availability,
.card-heading .status,
.card-heading select {
  flex: 0 0 auto;
  max-width: 46%;
}

.order-card .card-heading select {
  min-width: 118px;
  max-width: 148px;
}

.card-meta {
  row-gap: 7px;
}

.item-list div {
  min-width: 0;
  align-items: center;
}

.item-list strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-image-strip {
  max-height: 116px;
  overflow-y: auto;
  padding-right: 2px;
}

.product-card .actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.product-card .actions button {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-row,
.form-panel,
.landing-fieldset,
.bot-settings-grid,
.split {
  min-width: 0;
}

.form-panel {
  width: 100%;
}

#broadcast-tab #broadcast-form {
  display: grid;
  grid-template-columns: minmax(240px, .8fr) minmax(320px, 1.2fr);
  gap: 16px;
}

#broadcast-tab #broadcast-form > * {
  min-width: 0;
}

#broadcast-tab textarea {
  min-height: 132px;
}

#broadcast-tab .form-footer {
  align-self: end;
}

.history-title {
  align-items: center;
}

.announcement-card-image {
  max-height: 140px;
}

.announcement-card .actions {
  justify-content: flex-end;
}

.landing-maintenance-panel,
.landing-image-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.landing-maintenance-panel .setting-card-head,
.landing-maintenance-panel .status-box,
.landing-maintenance-panel .banner-actions,
.landing-image-form .setting-card-head,
.landing-image-form label,
.landing-image-form .status-box,
.landing-image-form .banner-preview,
.landing-image-form .note,
.landing-image-form .banner-actions,
.landing-image-form .form-footer {
  grid-column: auto;
}

.landing-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.landing-form > .status-box,
.landing-form > .form-footer,
.landing-form > .split,
.landing-form > label,
.landing-form > .landing-fieldset {
  grid-column: auto;
}

.landing-form > .landing-fieldset:first-of-type,
.landing-form > .landing-fieldset:nth-of-type(3),
.landing-form > .landing-fieldset:nth-of-type(4) {
  grid-row: auto;
}

.landing-fieldset {
  gap: 12px;
}

.landing-fieldset .split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#landing-tab {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
  width: min(100%, 1120px);
  margin-inline: auto;
}

#landing-tab > .section-title,
#landing-tab > .landing-form {
  grid-column: 1 / -1;
}

#landing-tab > .landing-maintenance-panel,
#landing-tab > .landing-image-form,
#landing-tab > .landing-form {
  min-width: 0;
}

#landing-tab .landing-maintenance-panel,
#landing-tab .landing-image-form {
  gap: 14px;
}

#landing-tab .landing-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

#landing-tab .landing-form > .status-box,
#landing-tab .landing-form > .form-footer {
  grid-column: 1 / -1;
}

#landing-tab .landing-form > .split,
#landing-tab .landing-form > label,
#landing-tab .landing-form > .landing-fieldset {
  min-width: 0;
}

#landing-tab .landing-fieldset {
  padding: 16px;
}

#broadcast-tab {
  width: min(100%, 1120px);
  margin-inline: auto;
}

#broadcast-tab #broadcast-form {
  grid-template-columns: minmax(250px, .82fr) minmax(0, 1.18fr);
  grid-template-areas:
    "status message"
    "emoji message"
    "upload message"
    "preview footer"
    "remove footer"
    "note footer";
  gap: 14px 18px;
}

#broadcast-tab #announcement-edit-id {
  display: none;
}

#broadcast-tab #broadcast-form .status-box {
  grid-area: status;
}

#broadcast-tab .emoji-picker {
  grid-area: emoji;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
}

#broadcast-tab .broadcast-message-wrap {
  grid-area: message;
}

#broadcast-tab .broadcast-upload {
  grid-area: upload;
}

#broadcast-tab #broadcast-image-preview {
  grid-area: preview;
  max-height: 150px;
  object-fit: contain;
  background: #fff;
}

#broadcast-tab #remove-broadcast-image-wrap {
  grid-area: remove;
}

#broadcast-tab .broadcast-note {
  grid-area: note;
}

#broadcast-tab .broadcast-footer {
  grid-area: footer;
  align-self: end;
}

#announcements-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-height: min(46vh, 500px);
}

.announcement-card {
  gap: 8px;
  padding: 13px;
  align-content: start;
}

.announcement-card .card-heading {
  align-items: start;
  gap: 8px;
}

.announcement-card .card-heading strong {
  font-size: 12px;
  line-height: 1.25;
}

.announcement-card-image {
  max-height: 118px;
  object-fit: contain;
  background: var(--surface-soft);
}

.announcement-text {
  max-height: 78px;
  padding: 9px 10px;
  background: var(--surface-soft);
  border-radius: 13px;
  font-size: 11.5px;
  line-height: 1.45;
}

#landing-tab .landing-form {
  display: block;
  column-count: 2;
  column-gap: 18px;
}

#landing-tab .landing-form > * {
  break-inside: avoid;
  margin: 0 0 18px;
}

#landing-tab .landing-form > .status-box,
#landing-tab .landing-form > .form-footer {
  column-span: all;
}

.bot-settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bot-settings-grid > * {
  min-width: 0;
}

@media (max-width: 1100px) {
  main { padding: 24px; }
  #dashboard-view {
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 16px;
    padding: 14px;
  }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #orders-body, #products-body, #announcements-list, #users-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-layout { grid-template-columns: 1fr; }
  .order-status-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #products-tab { width: 100%; }
  #landing-tab { grid-template-columns: 1fr; width: 100%; }
  #broadcast-tab { width: 100%; }
  #broadcast-tab #broadcast-form {
    grid-template-columns: 1fr;
    grid-template-areas:
      "status"
      "emoji"
      "message"
      "upload"
      "preview"
      "remove"
      "note"
      "footer";
  }
  #announcements-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: min(54vh, 560px); }
  #landing-tab .landing-form,
  .landing-form { grid-template-columns: 1fr; }
  #landing-tab .landing-form { column-count: 1; }
  .landing-form > .landing-fieldset:first-of-type,
  .landing-form > .landing-fieldset:nth-of-type(3),
  .landing-form > .landing-fieldset:nth-of-type(4) { grid-row: auto; }
}

@media (max-width: 720px) {
  body {
    background:
      radial-gradient(circle at 50% -10%, rgb(23 184 212 / .12) 0 230px, transparent 231px),
      #f2f5fa;
  }
  main { width: 100%; padding: 10px 10px 144px; }
  #dashboard-view {
    display: block;
    min-height: 100vh;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
  }
  #dashboard-view.hidden { display: none !important; }
  header {
    position: sticky;
    top: 0;
    z-index: 15;
    padding: 10px;
    background: rgb(242 245 250 / .86);
    border: 1px solid rgb(255 255 255 / .72);
    border-radius: 22px;
    backdrop-filter: blur(14px);
  }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
  .eyebrow { font-size: 9px; }
  h1 { font-size: 18px; }
  .system-status { display: none; }
  .header-actions { gap: 6px; }
  .header-actions button { min-height: 34px; padding: 7px 10px; font-size: 11px; }
  .tabs { display: none; }
  .mobile-tab-picker { display: none; }
  .mobile-app-nav {
    position: fixed;
    z-index: 30;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    background: rgb(255 255 255 / .94);
    border: 1px solid rgb(255 255 255 / .8);
    border-radius: 24px;
    box-shadow: 0 18px 50px rgb(25 36 55 / .18);
    backdrop-filter: blur(18px);
  }
  .mobile-app-nav button {
    min-width: 0;
    min-height: 44px;
    display: grid;
    place-items: center;
    gap: 2px;
    padding: 6px 2px;
    color: #8b95a7;
    background: transparent;
    border: 0;
    border-radius: 16px;
    box-shadow: none;
    font-size: 9px;
  }
  .mobile-app-nav button.active,
  .mobile-app-nav button:hover { color: #ffffff; background: var(--accent); }
  .mobile-app-nav svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .mobile-app-nav span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 850;
  }
  .tab-content {
    padding: 16px;
    border-radius: 24px;
  }
  .section-title {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
  }
  .section-title h2 { font-size: 19px; }
  .section-title p { font-size: 11px; }
  .section-title button { min-height: 34px; padding: 7px 10px; font-size: 11px; }
  .section-actions {
    width: 100%;
    justify-content: stretch;
  }
  .section-actions button {
    flex: 1 1 calc(50% - 6px);
  }
  .stats, .dashboard-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 14px;
    padding-top: 18px;
  }
  .stat { min-height: 94px; padding: 14px 62px 14px 14px; border-radius: 20px; }
  .stat-icon { top: 14px; right: 14px; width: 38px; height: 38px; border-width: 5px; border-radius: 14px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat strong { font-size: 21px; }
  .dashboard-layout, .bot-settings-grid, .split, .tool-row {
    grid-template-columns: 1fr;
  }
  .card-grid, .products-grid, .users-grid {
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
    padding: 0;
  }
  #orders-body, #announcements-list, #users-list { grid-template-columns: 1fr; }
  #products-body { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #broadcast-tab #broadcast-form,
  .landing-maintenance-panel,
  .landing-image-form,
  .landing-form,
  #landing-tab,
  #landing-tab .landing-form {
    grid-template-columns: 1fr;
  }
  #broadcast-tab #broadcast-form > .broadcast-side,
  #broadcast-tab #broadcast-form > .broadcast-main,
  .landing-maintenance-panel .setting-card-head,
  .landing-image-form .setting-card-head,
  .landing-image-form label,
  .landing-image-form .status-box,
  .landing-image-form .banner-preview,
  .landing-image-form .note,
  .landing-maintenance-panel .status-box,
  .landing-maintenance-panel .banner-actions,
  .landing-image-form .banner-actions,
  .landing-image-form .form-footer {
    grid-column: auto;
  }
  .landing-form > .landing-fieldset:first-of-type,
  .landing-form > .landing-fieldset:nth-of-type(3),
  .landing-form > .landing-fieldset:nth-of-type(4) { grid-row: auto; }
  .order-status-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  .order-status-tabs button {
    min-height: 58px;
    grid-template-columns: minmax(0, 1fr) 30px;
    padding: 10px;
    border-radius: 17px;
  }
  .order-status-tabs span { font-size: 10px; }
  .order-status-tabs strong { width: 28px; height: 28px; }
  .data-card, .dashboard-block, .panel { border-radius: 22px; }
  .data-card { padding: 14px; }
  .product-card { padding: 12px 34px 12px 12px; border-radius: 18px; gap: 8px; }
  .product-delete-x { top: 8px; right: 8px; width: 26px; min-height: 26px; font-size: 16px; }
  .product-card .card-heading { display: grid; grid-template-columns: 1fr; gap: 6px; }
  .product-card .card-heading strong { font-size: 12px; line-height: 1.25; }
  .product-card .card-kicker { font-size: 7px; }
  .product-card .availability { width: fit-content; min-height: 22px; padding: 4px 7px; font-size: 9px; }
  .product-image-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; max-height: none; }
  .product-image-strip figure:nth-of-type(n+3),
  .product-image-strip .product-image-more { display: none; }
  .product-summary { gap: 5px; }
  .product-summary span { min-height: 24px; padding: 4px 6px; font-size: 9px; }
  .product-summary b { font-size: 7px; }
  .card-heading {
    gap: 9px;
  }
  .card-heading .availability,
  .card-heading .status,
  .card-heading select {
    max-width: 52%;
  }
  .form-panel { max-width: none; padding: 16px; }
  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .form-footer button { width: 100%; }
  #banner-form, #welcome-form, #notification-target-form, #password-form {
    grid-column: auto;
    grid-row: auto;
  }
  .product-numbers, .user-details { grid-template-columns: 1fr 1fr; }
  .product-card .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-card .actions { gap: 5px; }
  .product-card .actions button { flex: 1 1 100%; min-height: 28px; padding: 6px 7px; font-size: 9px; }
  .landing-fieldset .split { grid-template-columns: 1fr; }
  .bot-settings-grid { grid-template-columns: 1fr; }
  .actions button { flex: 1 1 auto; }
  dialog { width: min(100%, calc(100% - 16px)); border-radius: 22px; }
  dialog form, .stock-dialog-content { padding: 16px; }
  #toast { right: 12px; bottom: 86px; }
}

@media (max-width: 420px) {
  .mobile-app-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats, .dashboard-stats { grid-template-columns: 1fr 1fr; }
  .product-numbers, .user-details { grid-template-columns: 1fr; }
  .order-status-tabs { grid-template-columns: 1fr; }
  .card-heading {
    display: grid;
    grid-template-columns: 1fr;
  }
  .card-heading .availability,
  .card-heading .status,
  .card-heading select {
    max-width: 100%;
    width: 100%;
  }
  #products-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-card .actions { grid-template-columns: 1fr; }
}
