:root {
  --bg: #f3f8ff;
  --panel: #ffffff;
  --line: #d7e6f8;
  --text: #14243a;
  --muted: #66758c;
  --accent: #007ffc;
  --accent-dark: #005fc7;
  --danger: #9f2f2f;
  --shadow: 0 10px 28px rgba(22, 54, 92, 0.08);

}

* { box-sizing: border-box; font-size: 12px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, sans-serif; }
button, input, select, textarea { font: inherit; }
button { background: var(--accent); border: 0; border-radius: 8px; color: #fff; cursor: pointer; font-weight: 800; min-height: 44px; padding: 12px 16px; }
button:hover { background: var(--accent-dark); }
a { color: inherit; text-decoration: none; }
.button-link { align-items: center; background: var(--accent); border-radius: 8px; color: #fff; display: inline-flex; font-weight: 900; justify-content: center; min-height: 44px; padding: 0 16px; white-space: nowrap; }
.button-link:hover { background: var(--accent-dark); }
.button-link--secondary { background: #eef5ff; color: var(--accent-dark); }
.button-link--secondary:hover { background: #dcecff; }
input, select, textarea { background: #fff; border: 1px solid var(--line); border-radius: 8px; color: var(--text); min-height: 44px; padding: 10px 12px; width: 100%; }
textarea { min-height: 110px; resize: vertical; }
label { display: grid; gap: 7px; font-weight: 800; color: var(--muted); }

.login { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login__card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); display: grid; gap: 16px; max-width: 440px; padding: 30px; width: 100%; }
.login__card img { height: 58px; object-fit: contain; object-position: left center; width: 190px; }
.login__card h1 { letter-spacing: 0; line-height: 1; margin: 4px 0; }
.login__card p { color: var(--muted); margin: 0; }
.login__card form { display: grid; gap: 14px; }

.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #fff; border-right: 1px solid var(--line); display: grid; grid-template-rows: auto 1fr auto; gap: 26px; height: 100vh; padding: 22px 18px; position: sticky; top: 0; }
.sidebar img { height: 48px; object-fit: contain; object-position: left center; width: 180px; }
.sidebar nav { display: grid; align-content: start; gap: 6px; }
.sidebar button,
.sidebar nav a { background: transparent; border-radius: 8px; color: var(--text); font-size: 14px; font-weight: 800; padding: 11px 14px; text-align: left; }
.sidebar button.is-active,
.sidebar button:hover,
.sidebar nav a:hover { background: #eaf3ff; color: var(--accent-dark); }
.sidebar .ghost { background: #eef5ff; color: var(--accent-dark); font-size: 14px; text-align: center; }
.logout-link { border-radius: 8px; display: block; font-size: 14px; font-weight: 900; padding: 12px 16px; }

.content { align-content: start; display: grid; gap: 18px; padding: 24px; }
.top { align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); display: flex; justify-content: space-between; min-height: 112px; padding: 22px 26px; }
.top p { color: var(--muted);  font-weight: 900; letter-spacing: 0.08em; margin: 0 0 6px; text-transform: uppercase; }
.top h1 { line-height: 1.05; margin: 0; }
#adminName { color: var(--accent-dark); font-weight: 900; }

.section { display: none; }
.section.is-active { display: grid; gap: 18px; }
.metrics { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.metric, .toolbar, .property-form, .notification-form, .file-list, .log, .table-wrap, .chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.metric { display: grid; gap: 6px; padding: 20px; }
.metric strong { color: var(--accent-dark);  }
.metric span { color: var(--muted); font-weight: 800; }

.charts { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-card { display: grid; gap: 12px; padding: 18px; }
.chart-card__title { font-size: 14px; font-weight: 800; margin: 0; }
.chart-card__canvas { height: 260px; position: relative; }
.chart-card__canvas--donut { height: 280px; max-width: 320px; }

.toolbar { align-items: flex-end; display: flex; flex-wrap: wrap; gap: 12px; padding: 16px; }
.toolbar__field { display: grid; gap: 7px; margin: 0; min-width: 160px; }
.toolbar__field--grow { flex: 1 1 280px; max-width: 480px; }
.toolbar__field input,
.toolbar__field select { width: 100%; }
.toolbar__actions { align-items: center; display: flex; flex: 0 0 auto; gap: 10px; }
.toolbar__actions button,
.toolbar__actions .button-link { margin: 0; }
.page-hint { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); color: var(--muted); font-weight: 700; margin: 0; padding: 14px 16px; }
.page-hint a { color: var(--accent-dark); font-weight: 800; text-decoration: underline; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 20px; }
.panel__title { font-size: 1.05rem; line-height: 1.2; margin: 0 0 16px; }

.coupon-form { display: grid; gap: 16px; }
.coupon-form__grid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.coupon-form__field { display: grid; gap: 7px; margin: 0; }
.coupon-form__field--wide { grid-column: span 3; }
.coupon-form__field input,
.coupon-form__field select { width: 100%; }
.coupon-form__checkbox { align-items: center; align-self: end; color: var(--text); display: flex; flex-direction: row; font-weight: 800; gap: 10px; margin: 0; min-height: 44px; }
.coupon-form__checkbox input { height: 18px; min-height: 18px; width: 18px; }
.coupon-form__actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }

.btn-link { border-radius: 8px; display: inline-flex; text-decoration: none; }
.cell-coupon strong { display: block; }
.cell-coupon__desc { color: var(--muted); display: block; font-weight: 600; margin-top: 3px; }
.table-cupons td { vertical-align: middle; }

.toolbar input { max-width: 420px; }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; min-width: 760px; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 12px; text-align: left; vertical-align: top; }
th { color: var(--muted); text-transform: uppercase; }
td button { padding: 8px 10px; }
.danger { background: var(--danger); }

.property-form, .notification-form { align-items: end; display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 18px; }
.property-form .wide, .notification-form .wide { grid-column: 1 / -1; }
.property-form button, .notification-form button { grid-column: 1 / -1; }

.terms-form { display: grid; gap: 16px; }
.editor-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.editor-toolbar { align-items: center; background: #f6faff; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; }
.editor-toolbar button { background: #fff; border: 1px solid var(--line); color: var(--text); min-height: 38px; padding: 8px 12px; }
.editor-toolbar button:hover { background: #eaf3ff; color: var(--accent-dark); }
.rich-editor { background: #fff; color: var(--text); line-height: 1.65; min-height: 420px; outline: none; padding: 22px; }
.rich-editor:focus { box-shadow: inset 0 0 0 2px rgba(0, 127, 252, 0.18); }
.rich-editor h2, .rich-editor h3, .rich-editor p, .rich-editor ul, .rich-editor ol, .rich-editor blockquote { margin: 0 0 14px; }
.rich-editor blockquote { border-left: 4px solid var(--line); color: var(--muted); padding-left: 14px; }
.rich-editor a { color: var(--accent-dark); font-weight: 800; text-decoration: underline; }
.terms-form > button { justify-self: stretch; }

.file-list { display: grid; gap: 10px; padding: 18px; }
.file-list label { align-items: center; background: #f6faff; border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 10px; padding: 12px; }
.file-list input { min-height: auto; width: auto; }
.log { color: var(--muted); min-height: 120px; overflow: auto; padding: 18px; white-space: pre-wrap; }
.feedback { background: #fff2f2; border: 1px solid #f1b8b8; border-radius: 8px; color: var(--danger); font-weight: 800; padding: 14px; }
.success { background: #edf8f1; border: 1px solid #bfe4cb; border-radius: 8px; color: #17683a; font-weight: 800; padding: 14px; }
.muted { color: var(--muted); font-weight: 800; }

.btn-sm {  font-weight: 800; min-height: 32px; padding: 6px 12px; }
.btn-ghost { background: #eef5ff; color: var(--accent-dark); }
.btn-ghost:hover { background: #dcecff; }
.btn-warning { background: #fff4e5; color: #9a5b00; }
.btn-warning:hover { background: #ffe8c7; }
.btn-danger-outline { background: #fff; border: 1px solid #e8b4b4; color: var(--danger); }
.btn-danger-outline:hover { background: #fff5f5; }

.badge { border-radius: 999px; display: inline-block;  font-weight: 800; letter-spacing: 0.04em; padding: 3px 8px; text-transform: uppercase; }
.badge--admin { background: #eef5ff; color: var(--accent-dark); margin-top: 6px; }

.status-badge { border-radius: 999px; display: inline-block; font-weight: 800; padding: 5px 10px; white-space: nowrap; }
.status-badge--active { background: #edf8f1; color: #17683a; }
.status-badge--inactive { background: #fff2f2; color: var(--danger); }

.table-users { min-width: 980px; }
.table-users th:last-child,
.table-users td:last-child { min-width: 320px; width: 320px; }
.table-users td { vertical-align: middle; }
.cell-id { color: var(--muted); font-weight: 800; width: 56px; }
.cell-user { min-width: 220px; }
.cell-user strong { display: block;  }
.cell-user__email { color: var(--muted); display: block; font-weight: 600; margin-top: 3px; word-break: break-word; }
.cell-date { color: var(--muted); white-space: nowrap; }

.user-actions { padding-top: 10px; padding-bottom: 10px; }
.user-actions__toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.user-actions__form { display: inline-flex; margin: 0; }
.user-actions__grant { align-items: center; background: #f6faff; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 8px; grid-template-columns: auto minmax(90px, 1fr) auto auto; margin: 0; padding: 8px; }
.user-actions__grant-label { color: var(--muted);  font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; }
.user-actions__grant select { min-height: 32px; padding: 4px 8px; width: auto; }
.user-actions__grant button { justify-self: end; white-space: nowrap; }

.table-actions { min-width: 140px; vertical-align: middle; }
.table-actions__row { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.table-actions__form { display: inline-flex; margin: 0; }
.table-actions .inline-form { align-items: center; display: inline-flex; flex-wrap: nowrap; gap: 6px; margin: 0 6px 6px 0; }
.table-actions .inline-form button { min-height: 32px; padding: 6px 10px; white-space: nowrap; }
.table-actions .inline-form select { min-height: 32px; padding: 4px 8px; width: auto; }

@media (max-width: 1100px) {
  .charts { grid-template-columns: 1fr; }
  .coupon-form__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coupon-form__field--wide { grid-column: span 2; }
  .user-actions__grant { grid-template-columns: 1fr 1fr; }
  .user-actions__grant-label { grid-column: 1 / -1; }
  .user-actions__grant button { grid-column: 1 / -1; justify-self: stretch; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  .metrics, .property-form, .notification-form, .coupon-form__grid { grid-template-columns: 1fr; }
  .coupon-form__field--wide { grid-column: auto; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar__field,
  .toolbar__field--grow { max-width: none; min-width: 0; width: 100%; }
  .toolbar__actions { width: 100%; }
  .toolbar__actions button,
  .toolbar__actions .button-link { flex: 1; }
  .toolbar input { max-width: none; }
}
