:root {
  --bg: #fff8e5;
  --paper: #ffffff;
  --ink: #271817;
  --muted: #756460;
  --line: #ead9bc;
  --red: #f20f0f;
  --red-dark: #c70b0b;
  --yellow: #fff200;
  --green: #2f7d62;
  --green-dark: #23644e;
  --blue: #315f8c;
  --danger: #b93618;
  --shadow: 0 18px 50px rgba(91, 35, 18, 0.15);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(255, 253, 243, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.admin-header a { color: var(--ink); font-weight: 850; text-decoration: none; }
.admin-brand { display: inline-flex; align-items: center; gap: 10px; }
.admin-brand img { object-fit: contain; filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.33)); }
.admin-header nav { display: flex; gap: 10px; align-items: center; }
.admin-header nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: #4d2a24;
}
.admin-header nav a:hover { background: #fff0c2; }

.admin-main { padding: 28px; max-width: 1380px; margin: 0 auto; }
h1 { margin: 0 0 8px; font-size: 38px; letter-spacing: 0; }
h2 { margin: 0; font-size: 24px; letter-spacing: 0; }
p { line-height: 1.5; }
.muted, .hint, small { color: var(--muted); }
.kicker { margin: 0 0 6px; text-transform: uppercase; font-size: 12px; font-weight: 900; color: var(--red); }

.admin-hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #fff0b8);
}
.admin-hero p:last-child { margin: 0; color: var(--muted); max-width: 680px; }
.hero-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stats-grid article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.stats-grid strong { display: block; font-size: 34px; }
.stats-grid span { color: var(--muted); font-weight: 700; }

.panel, .login-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin: 18px 0;
  box-shadow: 0 10px 28px rgba(25, 38, 31, 0.05);
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  margin-bottom: 16px;
}
.panel-title p { margin: 6px 0 0; color: var(--muted); }
.login-card { max-width: 420px; margin: 10vh auto; }
.error { padding: 10px 12px; border-radius: 8px; background: #fde8e1; color: var(--danger); }

form { display: grid; gap: 14px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
label { display: grid; gap: 7px; font-weight: 750; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  background: white;
}
.color-input {
  height: 44px;
  padding: 4px;
  cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 6px; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(242, 15, 15, 0.13);
  border-color: var(--red);
}
textarea { min-height: 96px; resize: vertical; }
button {
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: white;
  padding: 11px 14px;
  font-weight: 850;
  cursor: pointer;
}
button:hover { background: var(--red-dark); }
button.secondary {
  border: 1px solid var(--line);
  background: #f6f8f6;
  color: var(--ink);
}
button.secondary:hover { background: #fff0c2; }
button.ghost {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
}
button.small { padding: 8px 10px; font-size: 13px; }
.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; }
code { background: #edf1ee; padding: 2px 5px; border-radius: 5px; }

.admin-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.table-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(120px, 0.7fr) minmax(150px, 0.8fr) minmax(100px, 0.6fr) 96px;
  gap: 14px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}
.route-row { grid-template-columns: minmax(260px, 1.4fr) minmax(120px, 0.7fr) minmax(100px, 0.6fr) 96px; }
.category-row { grid-template-columns: minmax(220px, 1fr) minmax(130px, 0.5fr) minmax(160px, 0.7fr) 96px; }
.table-row:last-child { border-bottom: 0; }
.table-head { background: #fff3c7; color: var(--muted); font-size: 13px; font-weight: 900; text-transform: uppercase; }
.table-row span:first-child { display: grid; gap: 2px; }

.modal {
  width: min(1040px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
  overflow: auto;
}
.small-modal { width: min(720px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(16, 24, 20, 0.48); backdrop-filter: blur(3px); }
.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.modal form { padding: 18px; }

.ql-toolbar.ql-snow {
  border-color: var(--line);
  border-radius: 8px 8px 0 0;
  background: #fff8e5;
}
.ql-container.ql-snow {
  min-height: 220px;
  border-color: var(--line);
  border-radius: 0 0 8px 8px;
  font: inherit;
}
.ql-editor { min-height: 220px; font-size: 16px; line-height: 1.6; font-weight: 400; }
.ql-editor p, .ql-editor li { font-weight: 400; }
.ql-editor strong { font-weight: 800; }

.admin-map {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.gallery-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gallery-preview img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.opening-hours {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.opening-hours legend, .icon-picker legend { font-weight: 850; padding: 0 5px; }
.opening-day {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 220px;
  gap: 10px;
  align-items: start;
}
.no-hours { margin-bottom: 6px; }
.opening-intervals {
  display: grid;
  gap: 7px;
}
.opening-interval {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 7px;
}
.opening-actions {
  display: grid;
  gap: 8px;
}
.icon-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 48px;
  gap: 8px;
  align-items: center;
}
.icon-current {
  display: grid;
  place-items: center;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff3c7;
  font-size: 20px;
}
.icon-modal { width: min(980px, calc(100vw - 28px)); }
.icon-modal-body { padding: 18px; display: grid; gap: 14px; }
.icon-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
  max-height: 62vh;
  overflow: auto;
}
.icon-modal-grid button {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 82px;
  padding: 10px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}
.icon-modal-grid button:hover { background: #fff0c2; }
.icon-modal-grid i { font-size: 24px; color: var(--red); }
.icon-modal-grid span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.color-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--swatch);
  vertical-align: middle;
  margin-right: 8px;
  border: 1px solid rgba(0,0,0,0.1);
}

@media (max-width: 900px) {
  .admin-hero, .panel-title { flex-direction: column; align-items: stretch; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-table { border: 0; gap: 10px; }
  .table-head { display: none; }
  .table-row, .route-row {
    grid-template-columns: 1fr;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
  }
  .opening-day, .opening-interval { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .admin-header { flex-direction: column; align-items: flex-start; padding: 14px 18px; }
  .admin-header nav { flex-wrap: wrap; }
  .admin-main { padding: 18px; }
  h1 { font-size: 32px; }
}
