:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #637083;
  --line: #d9e0e8;
  --surface: #ffffff;
  --page: #f4f7fa;
  --nav: #12233d;
  --accent: #007c78;
  --accent-dark: #006460;
  --danger: #ba3434;
  --success: #167241;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell { height: 100vh; min-height: 0; display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.sidebar { min-height: 0; overflow-y: auto; background: var(--nav); color: #d8e4f3; padding: 22px 14px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 8px 30px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; }
.brand img { width: 32px; height: 32px; object-fit: contain; }
.brand span { display: block; font-size: 12px; color: #93abc6; font-weight: 400; margin-top: 2px; }
.nav-link { display: block; padding: 10px 12px; border-radius: 5px; color: #bdd0e5; text-decoration: none; margin: 3px 0; }
.nav-link:hover, .nav-link.active { background: #1d385e; color: #fff; }
.sidebar nav { flex: 1; }
.sidebar-footer { margin: 28px 8px 0; color: #93abc6; font-size: 12px; display: grid; gap: 9px; }
.sidebar-signout { color: #d8e4f3; text-decoration: none; font-size: 13px; }
.sidebar-signout:hover { color: #fff; }
.main { min-width: 0; min-height: 0; overflow-y: auto; }
.topbar { height: 64px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; }
.account { display: none; }
.content { max-width: 1320px; margin: 0 auto; padding: 28px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-heading h2 { margin: 0; font-size: 22px; }
.page-heading p { color: var(--muted); margin: 5px 0 0; }
.grid { display: grid; gap: 18px; }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.grid.two { grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 20px; }
.panel h3 { margin: 0 0 16px; font-size: 15px; }
.metric .value { font-size: 30px; font-weight: 700; }
.metric .label { color: var(--muted); margin-top: 4px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); font-size: 12px; font-weight: 650; text-align: left; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-block; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 650; }
.status.active { background: #dff5e8; color: var(--success); }
.status.pending { background: #fff2cd; color: #8a6500; }
.status.disabled, .status.expired { background: #fde3e3; color: var(--danger); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 13px; border: 1px solid transparent; border-radius: 5px; text-decoration: none; background: var(--accent); color: #fff; font-weight: 600; }
.button:hover { background: var(--accent-dark); }
.button:focus-visible { outline: 3px solid rgba(0, 124, 120, .42); outline-offset: 2px; }
.button.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.button.secondary:hover { background: #edf3f7; border-color: #b6c4d2; }
.button.danger { background: var(--danger); }
.button.danger:hover { background: #962a2a; }
.button.small { min-height: 30px; padding: 0 9px; font-size: 12px; }
.button.icon-button { width: 30px; min-width: 30px; padding: 0; font-size: 16px; line-height: 1; }
.window-actions { display: flex; align-items: center; gap: 6px; }
.window-actions .inline-form { display: flex; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
label { display: block; font-size: 12px; font-weight: 650; margin-bottom: 6px; color: #405068; }
input, select, textarea { width: 100%; min-height: 36px; border: 1px solid #c7d1dc; border-radius: 4px; padding: 8px 9px; background: #fff; color: var(--ink); }
textarea { min-height: 86px; resize: vertical; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; }
.field-action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.telegram-chat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.weekday-picker { display: flex; flex-wrap: wrap; gap: 8px 12px; min-height: 36px; align-items: center; }
.weekday-picker label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: 13px; font-weight: 500; color: var(--ink); }
.weekday-picker input { width: auto; min-height: 0; margin: 0; }
.telegram-actions { align-items: center; flex-wrap: wrap; }
.telegram-actions form { margin: 0; }
.telegram-action-guide { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.telegram-action-guide strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 12px; }
.telegram-action-guide span { display: block; }
.alert { border-radius: 5px; padding: 11px 13px; margin-bottom: 18px; }
.alert.success { background: #e5f6eb; color: #135e35; }
.alert.error { background: #fde7e7; color: #952a2a; }
.code-box { background: #0e1b2e; color: #eff7ff; padding: 12px; border-radius: 5px; font-family: Consolas, monospace; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.inline-form { display: inline; }
.table-wrap td > .button + .inline-form { margin-left: 6px; }
.customer-actions .inline-form { margin: 0; }
.customer-details-form { max-width: 760px; }
.upload-progress { display: grid; gap: 7px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.upload-progress__track { height: 8px; overflow: hidden; border-radius: 4px; background: #dfe7ee; }
.upload-progress__bar { width: 0; height: 100%; background: var(--accent); transition: width .16s ease; }
.upload-progress__bar.indeterminate { width: 35%; animation: upload-progress 1.1s ease-in-out infinite; }
@keyframes upload-progress { from { transform: translateX(-120%); } to { transform: translateX(340%); } }
.confirm-modal[hidden] { display: none; }
.confirm-modal { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 20px; }
.confirm-modal__backdrop { position: absolute; inset: 0; background: rgba(14, 27, 46, .48); }
.confirm-modal__dialog { position: relative; width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 22px; box-shadow: 0 18px 48px rgba(14, 27, 46, .26); }
.confirm-modal__dialog h2 { margin: 0; font-size: 17px; }
.confirm-modal__dialog p { margin: 10px 0 0; color: var(--muted); }
.confirm-modal__actions { justify-content: flex-end; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: #eaf0f5; padding: 20px; }
.login-card { width: min(360px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 26px; }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.login-brand img { width: 38px; height: 38px; }
.login-brand-copy { min-width: 0; }
.login-brand-title, .login-brand-subtitle { display: block; }
.login-brand-title { font-size: 19px; font-weight: 700; line-height: 1.15; }
.login-brand-subtitle { margin-top: 3px; color: var(--muted); font-size: 12px; }
.password-input { position: relative; }
.password-input input { padding-right: 44px; }
.password-toggle { position: absolute; top: 1px; right: 1px; width: 34px; height: 34px; border: 0; background: transparent; color: #53657c; font-size: 16px; line-height: 1; }
.password-toggle:hover { color: var(--accent-dark); }
.password-toggle:focus-visible { outline: 3px solid rgba(0, 124, 120, .42); outline-offset: -2px; }

@media (max-width: 900px) {
  .shell { height: auto; min-height: 100vh; grid-template-columns: 1fr; grid-template-rows: auto; }
  .sidebar { min-height: auto; overflow-y: visible; padding: 12px; display: flex; align-items: center; gap: 6px; overflow-x: auto; }
  .main { overflow-y: visible; }
  .brand { margin: 0 12px 0 0; white-space: nowrap; }
  .brand span, .sidebar-footer { display: none; }
  .nav-link { white-space: nowrap; }
  .grid.metrics, .grid.two { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .grid.metrics, .grid.two, .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .telegram-chat-row { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .telegram-action-guide { grid-template-columns: 1fr; }
}
