:root {
  color-scheme: light;
  --ink: #173233;
  --muted: #667b7b;
  --line: #dce9e6;
  --paper: #ffffff;
  --wash: #f4f8f7;
  --teal: #0f766e;
  --teal-dark: #0a5c56;
  --teal-pale: #e8f5f2;
  --amber: #d97706;
  --danger: #b42318;
  --shadow: 0 22px 55px rgba(21, 54, 51, .13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--wash); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #d9f1eb 0, transparent 34%), linear-gradient(135deg, #f7fbfa, #e6f2ef); }
.login-card { width: min(100%, 430px); padding: 38px; background: rgba(255,255,255,.96); border: 1px solid rgba(255,255,255,.8); border-radius: 28px; box-shadow: var(--shadow); }
.login-brand, .brand-lockup { display: flex; align-items: center; gap: 13px; }
.login-brand img { width: 62px; height: 62px; border-radius: 18px; box-shadow: 0 9px 25px rgba(15,118,110,.2); }
.login-brand span, .brand-lockup span { display: block; color: var(--teal); font-weight: 750; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.login-brand h1 { margin: 2px 0 0; font-size: 30px; letter-spacing: -.03em; }
.login-intro { margin: 24px 0; color: var(--muted); line-height: 1.65; }
.stack-form { display: grid; gap: 17px; }
.stack-form label { display: grid; gap: 7px; font-weight: 700; font-size: 14px; }
.stack-form .check-label { display: flex; font-weight: 500; }
input, select, textarea { min-height: 46px; width: 100%; padding: 0 14px; color: var(--ink); background: #fff; border: 1px solid #cddfdb; border-radius: 12px; outline: none; }
textarea { padding-block: 12px; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.primary-button, .secondary-button { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 0; font-weight: 750; }
.primary-button { color: #fff; background: var(--teal); }
.primary-button:hover { background: var(--teal-dark); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { color: var(--teal); background: var(--teal-pale); border: 1px solid #c5e5df; }
.form-error { min-height: 20px; margin: 14px 0 0; color: var(--danger); font-size: 14px; }

.app-view { min-height: 100vh; }
.app-header { height: 74px; padding: 0 clamp(18px, 4vw, 58px); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #fff; background: #123c3a; }
.brand-lockup img { width: 44px; height: 44px; border-radius: 12px; }
.brand-lockup span { color: #86d8ce; font-size: 10px; }
.brand-lockup strong { display: block; margin-top: 1px; font-size: 20px; }
.account-block { display: flex; align-items: center; gap: 12px; }
.account-copy { display: grid; text-align: right; }
.account-copy strong { font-size: 14px; }
.account-copy span { color: #b9d3d0; font-size: 12px; }
.role-badge { padding: 6px 9px; border-radius: 999px; background: #d8f3ee; color: #0a5c56; font-size: 12px; font-weight: 800; }
.role-badge.admin { color: #854d0e; background: #fef3c7; }
.icon-button { width: 38px; height: 38px; color: #fff; font-size: 20px; border: 1px solid rgba(255,255,255,.2); border-radius: 10px; background: rgba(255,255,255,.08); }
.toolbar { position: sticky; top: 0; z-index: 20; padding: 14px clamp(18px, 4vw, 58px); display: grid; grid-template-columns: minmax(240px, 1fr) minmax(170px, 250px) auto auto; align-items: center; gap: 12px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.search-box { min-height: 46px; display: flex; align-items: center; gap: 9px; padding-left: 14px; background: #fff; border: 1px solid #cddfdb; border-radius: 12px; }
.search-box span { font-size: 25px; color: var(--teal); }
.search-box input { min-height: 42px; padding-left: 0; border: 0; box-shadow: none; }
.last-update { min-height: 42px; display: flex; align-items: center; padding: 0 13px; color: #0a5c56; background: #e8f5f2; border: 1px solid #c5e5df; border-radius: 999px; white-space: nowrap; font-size: 13px; font-weight: 750; }
.last-update::before { content: ''; width: 8px; height: 8px; margin-right: 8px; background: #15a394; border-radius: 50%; box-shadow: 0 0 0 3px rgba(21,163,148,.14); }
.last-update.empty { color: var(--muted); background: var(--wash); border-color: var(--line); }
.last-update.empty::before { background: #9aabaa; box-shadow: none; }
.last-update.offline { color: #854d0e; background: #fff7df; border-color: #f1d899; }
.last-update.offline::before { background: #d97706; box-shadow: 0 0 0 3px rgba(217,119,6,.13); }

.admin-panel { padding: 22px clamp(18px, 4vw, 58px) 0; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.account-panel { padding: 22px clamp(18px, 4vw, 58px) 0; }
.password-card { max-width: 760px; margin-left: auto; }
.password-form { margin-top: 18px; display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 10px; }
.panel-card { padding: 22px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 22px rgba(21,54,51,.05); }
.panel-heading { display: flex; gap: 13px; }
.panel-icon { flex: 0 0 38px; height: 38px; display: grid; place-items: center; color: var(--teal); background: var(--teal-pale); border-radius: 11px; font-size: 22px; }
.panel-heading h2 { margin: 0; font-size: 18px; }
.panel-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.upload-zone { min-height: 118px; margin-top: 18px; display: grid; place-items: center; align-content: center; gap: 5px; text-align: center; color: var(--teal); background: #f3faf8; border: 1.5px dashed #81c7bd; border-radius: 15px; cursor: pointer; }
.upload-zone span { color: var(--muted); font-size: 12px; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.update-card { grid-column: span 2; }
.compact-upload { min-height: 92px; }
.user-form { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.user-form .primary-button { grid-column: span 2; }
.user-list { margin-top: 15px; display: grid; gap: 8px; max-height: 210px; overflow: auto; }
.user-item { padding: 10px 12px; display: flex; justify-content: space-between; gap: 10px; background: var(--wash); border-radius: 10px; font-size: 13px; }
.user-item span { color: var(--muted); }
.user-item { align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.user-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-actions button { padding: 8px 12px; min-height: 40px; }
.user-actions .delete-user { color: #a52a20; background: #fff0ed; }
.user-actions button:disabled { opacity: .45; cursor: not-allowed; }
.promo-admin-card { grid-column: 1 / -1; }
.promo-form { margin-top: 18px; display: grid; grid-template-columns: 1.4fr 1fr .8fr .7fr .8fr .8fr; gap: 10px; align-items: end; }
.promo-form textarea { grid-column: 1 / span 4; min-height: 82px; resize: vertical; }
.field-label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.field-label input { width: 100%; }
.check-label { min-height: 44px; display: flex; align-items: center; gap: 9px; font-size: 13px; }
.check-label input { width: 18px; height: 18px; accent-color: var(--teal); }
.promo-form-actions { display: flex; gap: 9px; }
.promo-admin-list { margin-top: 16px; display: grid; gap: 9px; }
.promo-admin-item { padding: 13px 14px; display: flex; justify-content: space-between; align-items: center; gap: 14px; background: #f4f8f7; border: 1px solid var(--line); border-radius: 12px; }
.promo-admin-copy { min-width: 0; display: grid; gap: 3px; }
.promo-admin-copy span { color: var(--muted); font-size: 12px; }
.promo-admin-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.promo-admin-actions .secondary-button { min-height: 34px; padding: 6px 11px; }

.content-wrap { padding: 22px clamp(18px, 4vw, 58px) 50px; }
.file-meta { margin-bottom: 14px; padding: 11px 14px; color: #315b57; background: #e9f5f2; border-radius: 11px; font-size: 13px; }
.status-box { margin-bottom: 16px; padding: 14px 16px; color: #315b57; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.empty-state { min-height: 280px; display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; color: var(--muted); }
.empty-state .empty-icon { font-size: 42px; color: #8ab9b3; }
.empty-state h2 { margin: 0; color: var(--ink); }
.empty-state p { margin: 0; }
.result-count { color: var(--muted); font-size: 14px; }
.promo-dashboard { margin-bottom: 18px; }
.promo-dashboard-head { margin-bottom: 10px; display: flex; align-items: center; gap: 9px; }
.promo-dashboard-head h2 { margin: 0; font-size: 20px; }
.promo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.promo-card { position: relative; overflow: hidden; min-height: 128px; padding: 18px; display: grid; align-content: center; gap: 7px; color: #fff; background: linear-gradient(135deg, #0f766e, #159a8d); border-radius: 16px; box-shadow: 0 8px 20px rgba(15,118,110,.2); }
.promo-card::after { content: '%'; position: absolute; right: 12px; bottom: -24px; color: rgba(255,255,255,.12); font-size: 110px; font-weight: 900; line-height: 1; }
.promo-card.no-discount::after { content: '★'; }
.promo-card > * { position: relative; z-index: 1; }
.promo-card-edit { justify-self: start; min-height: 36px; padding: 6px 12px; color: #0b514b; background: #fff; border: 0; border-radius: 9px; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.promo-card-edit:hover { background: #e7f7f3; }
.promo-brand { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
.promo-title { font-size: 18px; font-weight: 850; }
.promo-discount { font-size: 24px; font-weight: 900; }
.promo-description, .promo-period { font-size: 12px; opacity: .9; }
.promo-inline { margin: 2px 0 15px; }
.promo-inline .promo-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.promo-inline .promo-card { min-height: 112px; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 13px; }
.brand-card { min-height: 98px; padding: 18px; display: grid; align-content: center; gap: 7px; text-align: left; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 12px rgba(21,54,51,.04); }
.brand-card:hover { border-color: #83bfb7; transform: translateY(-1px); }
.brand-card strong { font-size: 16px; }
.brand-card span { color: var(--muted); font-size: 13px; }
.brand-card .promo-badge { width: fit-content; padding: 4px 8px; color: #8a3f00; background: #fff1cf; border-radius: 999px; font-size: 11px; font-weight: 800; }
.section-title { margin: 4px 0; font-size: 23px; }
.sheet-navigation { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 0; background: var(--wash); }
.sheet-back-button { min-height: 40px; padding: 8px 13px; color: var(--teal); background: #fff; border: 1px solid #b9d9d3; border-radius: 10px; font: inherit; font-size: 13px; font-weight: 750; cursor: pointer; }
.sheet-back-button:hover { background: var(--teal-pale); }
.section-note { margin: 0 0 13px; color: var(--muted); font-size: 13px; }
.table-frame { max-width: 100%; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 5px 18px rgba(21,54,51,.05); }
.table-frame table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.table-frame td { min-width: 105px; padding: 8px 11px; border: 1px solid #e2ecea; vertical-align: middle; font-size: 13px; }
.table-frame tr:nth-child(even) td { background: #f8fbfa; }
.table-frame .product-image { display: block; max-width: 135px; max-height: 105px; object-fit: contain; margin: 2px auto; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 13px; }
.result-card { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 15px; }
.result-head { padding: 10px 13px; display: flex; justify-content: space-between; color: var(--teal); background: #eef8f6; font-size: 12px; }
.result-body { padding: 13px; display: flex; gap: 13px; }
.result-images { flex: 0 0 90px; }
.result-images img { width: 90px; height: 82px; object-fit: contain; border: 1px solid var(--line); border-radius: 9px; }
.result-values { display: grid; gap: 5px; align-content: center; min-width: 0; }
.result-values span { overflow-wrap: anywhere; font-size: 13px; }
.toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: min(390px, calc(100vw - 36px)); padding: 13px 16px; color: #fff; background: #173f3c; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #8f281f; }

@media (max-width: 820px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-box { grid-column: span 2; }
  .last-update { grid-column: span 2; justify-content: center; border-radius: 12px; }
  .admin-panel { grid-template-columns: 1fr; }
  .promo-admin-card { grid-column: auto; }
  .promo-form { grid-template-columns: 1fr 1fr; }
  .promo-form textarea { grid-column: 1 / -1; }
  .promo-form-actions { grid-column: 1 / -1; }
  .password-form { grid-template-columns: 1fr 1fr; }
  .password-form .primary-button { grid-column: span 2; }
  .update-card { grid-column: auto; }
  .account-copy { display: none; }
}
@media (max-width: 560px) {
  .login-card { padding: 27px 22px; border-radius: 22px; }
  .app-header { height: 66px; padding-inline: 14px; }
  .brand-lockup img { width: 38px; height: 38px; }
  .role-badge { display: none; }
  .toolbar { padding: 11px 14px; }
  .toolbar select, .toolbar .secondary-button { min-width: 0; padding-inline: 10px; }
  .admin-panel, .content-wrap { padding-inline: 14px; }
  .account-panel { padding: 14px 14px 0; }
  .password-form { grid-template-columns: 1fr; }
  .password-form .primary-button { grid-column: auto; }
  .user-form { grid-template-columns: 1fr; }
  .user-form .primary-button { grid-column: auto; }
  .promo-form { grid-template-columns: 1fr; }
  .promo-form textarea, .promo-form-actions { grid-column: auto; }
  .promo-form-actions { display: grid; }
  .promo-admin-item { align-items: flex-start; flex-direction: column; }
  .promo-admin-actions { width: 100%; }
  .promo-admin-actions button { flex: 1; }
  .promo-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .table-frame { border-radius: 11px; }
}
