:root {
  --bg: #eef3f1;
  --card: #ffffff;
  --line: #dbe5e0;
  --text: #1f2c28;
  --muted: #6b7c75;
  --brand: #2c675a;
  --brand-soft: #e5f2ed;
  --brand-strong: #153e35;
  --accent: #c98b3c;
  --ok: #20875e;
  --danger: #c05a51;
  --shadow: 0 12px 30px rgba(21, 62, 53, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(201, 139, 60, 0.08), transparent 28%),
    linear-gradient(180deg, #f7fbf9 0%, var(--bg) 100%);
  color: var(--text);
  line-height: 1.35;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(219, 229, 224, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-brand { display: flex; align-items: center; }

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-strong);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-link {
  color: var(--brand-strong);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.logout-link { background: #edf5f1; }
.logout-link:hover { background: #e5f0eb; }

.admin-layout {
  display: grid;
  grid-template-columns: 245px 1fr;
  min-height: calc(100vh - 73px);
}

.sidebar {
  background: rgba(246, 250, 248, 0.94);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
}

.side-nav { display: flex; flex-direction: column; gap: 14px; }

.nav-group-title {
  margin: 0 0 6px 10px;
  color: #7a8c84;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.side-nav a {
  display: block;
  text-decoration: none;
  color: #36584e;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.side-nav a:hover { background: #edf5f1; }

.side-nav a.active {
  background: linear-gradient(135deg, #e4f1eb 0%, #f3f9f6 100%);
  color: var(--brand-strong);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(44, 103, 90, 0.1);
}

.side-nav a.sub-link {
  margin-left: 12px;
  padding: 6px 10px;
  color: #698077;
  font-size: 13px;
}

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 24px 32px;
}

h1 { margin: 0 0 8px; font-size: 34px; font-weight: 700; color: var(--brand-strong); }
h2 { margin: 0 0 8px; font-size: 22px; color: var(--brand-strong); }
h3 { margin: 0; }
.lead { margin: 0; color: var(--muted); font-size: 15px; }

a.section-tab {
  text-decoration: none;
  color: #48655b;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
}

a.section-tab.active {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.settings-section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.page-head,
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.page-head {
  margin-bottom: 18px;
}

.page-head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.section-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-section {
  margin-bottom: 18px;
}

.grid,
.summary-grid,
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.priority-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 12px;
}

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(21, 62, 53, 0.05);
}

.summary-card,
.info-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--brand-strong);
}

.summary-card-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.summary-card-note {
  color: var(--muted);
  font-size: 13px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric h3 { font-size: 13px; color: var(--muted); font-weight: 600; }
.metric p { margin: 0; font-size: 34px; font-weight: 700; color: var(--brand); }

.metric-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #eef3ef;
}

.metric-inline:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.metric-inline-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-inline-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-strong);
}

.attention-card {
  background: linear-gradient(180deg, #fff8ef 0%, #ffffff 100%);
  border-color: #efd8b8;
}

.attention-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.attention-list li + li {
  margin-top: 8px;
}

.empty-state {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-strong);
  font-size: 16px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}

.status-dot.ok { background: var(--ok); }
.status-dot.warn { background: var(--accent); }
.status-dot.neutral { background: #98aaa2; }
.status-dot.danger { background: var(--danger); }

.stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.table-card-body {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: #f9fcfa; }

th {
  background: #f6faf8;
  color: #50655d;
  font-weight: 600;
  white-space: nowrap;
}

input, textarea, button, select {
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
}

textarea { resize: vertical; }

button, .btn {
  width: auto;
  border: 0;
  border-radius: 999px;
  background: #286c8c;
  color: #fff;
  text-decoration: none;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 600;
  display: inline-block;
}

.btn-primary { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%); }

.btn-soft {
  background: #edf5f1;
  color: var(--brand-strong);
  border: 1px solid var(--line);
}

.field { display: block; margin-bottom: 12px; }
.field span { font-weight: 600; font-size: 14px; }
.field small { display: block; font-size: 12px; color: var(--muted); margin: 2px 0 4px; }
.setting-key { display: block; margin-top: 6px; color: #74828f; font-size: 12px; }

.switch-row { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; }
.switch-row input[type="checkbox"] {
  width: 44px;
  height: 24px;
  appearance: none;
  border: 1px solid #c9d7e2;
  border-radius: 999px;
  background: #e9eff4;
  position: relative;
  cursor: pointer;
}

.switch-row input[type="checkbox"]::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  box-shadow: 0 1px 2px rgba(20, 40, 60, 0.2);
}

.switch-row input[type="checkbox"]:checked { background: #d9f0e7; border-color: #9fceb9; }
.switch-row input[type="checkbox"]:checked::after { left: 22px; }
.switch-label { color: #4e6472; font-size: 13px; }

.choice-group { display: inline-flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.choice-item { cursor: pointer; }
.choice-item input { position: absolute; opacity: 0; pointer-events: none; }

.choice-item span {
  display: inline-block;
  border: 1px solid #cfe0ea;
  border-radius: 999px;
  padding: 6px 11px;
  background: #fff;
  color: #3d6073;
  font-size: 13px;
}

.choice-item input:checked + span {
  background: #e7f3fb;
  border-color: #a8cbe0;
  color: #174d6b;
  font-weight: 600;
}

.form-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.single-row-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.logs-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr)) auto;
  gap: 8px;
  align-items: end;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 14px;
  align-items: start;
}

.settings-main {
  min-width: 0;
}

.sticky-panel {
  position: sticky;
  top: 92px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field-card {
  border: 1px solid #edf2ef;
  border-radius: 14px;
  padding: 14px;
  background: #fbfdfc;
}

.field-card textarea,
.field-card input {
  margin-top: 8px;
}

.chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf1f4;
  color: #596a77;
  font-size: 12px;
}

.ok-chip { background: #e2f4ec; color: var(--ok); }
.danger-chip { background: #f9e5e3; color: var(--danger); }

.builder-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 14px; }
.pill-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.pill {
  border: 1px solid #c9dae5;
  border-radius: 999px;
  background: #f6fbff;
  color: #1f4f69;
  padding: 6px 10px;
  cursor: pointer;
}

.pill.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand-strong);
}

.pill-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.setting-time-hint {
  font-size: 13px;
  color: var(--ok);
  margin-top: 4px;
}

.days-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Sidebar badges */
.nav-badge {
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: auto;
  min-width: 18px;
  text-align: center;
}

.side-nav a {
  display: flex;
  align-items: center;
}

/* Chips and Statuses */
.chip {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.ok-chip {
  background: #e6ffed;
  color: #22863a;
}

.danger-chip {
  background: #ffeef0;
  color: #cb2431;
}

/* Date formatting styles */
/* Actor roles in logs */
.actor-role-chip {
  font-size: 13px;
  font-weight: 500;
  display: inline-block;
  padding: 1px 0;
}

.role-admin { color: #d73a49; font-weight: 600; }
.role-cashier { color: #005cc5; }
.role-client { color: #22863a; }
.role-system { color: #6a737d; font-style: italic; }

.js-date-format {
  cursor: help;
  border-bottom: 1px dotted #ccc;
}

.template-placeholders-scroll {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 6px;
}

.template-pills {
  margin-bottom: 0;
  align-content: flex-start;
}

.template-pills .pill {
  padding: 8px 12px;
  font-size: 13px;
}

.template-hint-list {
  margin-top: 12px;
  font-size: 13px;
}

.preview-box {
  min-height: 120px;
  border: 1px dashed #c5d5e0;
  border-radius: 8px;
  padding: 10px;
  background: #fafcfe;
  white-space: pre-wrap;
}

.qr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; }
.qr-card h2 { margin: 0 0 8px; font-size: 18px; }

.qr-preview {
  width: 100%;
  max-width: 220px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}

.qr-card code {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  word-break: break-all;
  color: #4d6778;
  font-size: 12px;
}

.qr-style-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.qr-style-form label { display: flex; gap: 8px; align-items: center; }

.qr-style-form input[type="color"] {
  width: 42px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(145deg, #dceaf4, #f5f7fa);
}

.login-card { width: 360px; }
.error { color: var(--danger); margin: 8px 0 0; }
.ok { color: var(--ok); }

@media (max-width: 760px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .topbar {
    padding: 12px 14px;
    align-items: flex-start;
  }
  .topbar-title { font-size: 15px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .container { padding: 14px 12px; }
  .page-head,
  .section-header { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .single-row-form { grid-template-columns: 1fr; }
  .logs-filters { grid-template-columns: 1fr; }
  .builder-grid { grid-template-columns: 1fr; }
  .split-layout { grid-template-columns: 1fr; }
  .priority-grid { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  h1 { font-size: 24px; }
}


/* Reply box styling for admin messages */
.reply-box {
  margin-top: 8px;
  padding: 8px;
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
}

.btn-sm {
  font-size: 12px;
  padding: 4px 8px;
}

.autocomplete-items {
  position: absolute;
  border: 1px solid var(--border);
  border-bottom: none;
  border-top: none;
  z-index: 99;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.autocomplete-items div {
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
}
.autocomplete-items div:hover {
  background-color: var(--bg-body);
}
.autocomplete-active {
  background-color: var(--accent) !important;
  color: #ffffff;
}

/* Tabs for templates settings */
.sub-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.sub-tab {
  background: none;
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  transition: all 0.2s;
}
.sub-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}
.sub-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Template editor improvements */
.template-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.template-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--bg-body);
  padding: 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.template-toolbar .pill {
  font-size: 11px;
  padding: 3px 6px;
}
.template-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
@media (max-width: 900px) {
  .template-split {
    grid-template-columns: 1fr;
  }
}
.template-preview-box {
  background: #f0f2f5;
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.4;
  color: #000;
  white-space: pre-wrap;
  position: relative;
  border: 1px solid #ddd;
  min-height: 100px;
}
.template-preview-box::before {
  content: "Предпросмотр (Пример)";
  position: absolute;
  top: -8px;
  right: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: bold;
}
.template-preview-placeholder {
  color: #888;
  font-style: italic;
}
.template-preview-var {
  color: var(--accent);
  font-weight: bold;
}

/* Broadcast specific layout */
.broadcast-layout {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1000px) {
  .broadcast-layout {
    grid-template-columns: 1fr;
  }
}
.broadcast-form {
  margin-bottom: 0;
}
.broadcast-preview .sticky-panel {
  position: sticky;
  top: 20px;
}
