/* ---------- Темы ---------- */

[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e3e6eb;
  --sidebar-bg: #ffffff;
  --sidebar-text: #1f2328;
  --sidebar-hover: #f1f3f6;
  --sidebar-active: #e8eefc;
  --sidebar-accent: #2563eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text: #ffffff;
  --th-bg: #f7f8fa;
  --selected-bg: #eef4ff;
  --input-bg: #ffffff;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --bad-bg: #fee2e2;
  --bad-text: #991b1b;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --radius: 6px;
  --font-body: "Segoe UI", Arial, sans-serif;
  --font-head: "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}

[data-theme="warm"] {
  --bg: #f6efe6;
  --surface: #fffdf9;
  --text: #3b2a20;
  --muted: #8a7565;
  --border: #e6d9c8;
  --sidebar-bg: #4a3328;
  --sidebar-text: #f3e9dc;
  --sidebar-hover: #5a4033;
  --sidebar-active: #6b4c3b;
  --sidebar-accent: #d8a46f;
  --accent: #b5673e;
  --accent-hover: #96502d;
  --accent-text: #ffffff;
  --th-bg: #f3e8da;
  --selected-bg: #f7e6cf;
  --input-bg: #fffdf9;
  --ok-bg: #dfeadb;
  --ok-text: #3d6b35;
  --bad-bg: #f5dcd3;
  --bad-text: #8a3b22;
  --danger: #8a3b22;
  --shadow: 0 1px 3px rgba(74, 51, 40, 0.12);
  --radius: 10px;
  --font-body: "Segoe UI", Arial, sans-serif;
  --font-head: Georgia, "Times New Roman", serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #16181d;
  --surface: #21242b;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --border: #2f343e;
  --sidebar-bg: #111318;
  --sidebar-text: #d6dae2;
  --sidebar-hover: #1c1f26;
  --sidebar-active: #262b35;
  --sidebar-accent: #f0b429;
  --accent: #f0b429;
  --accent-hover: #d99e1c;
  --accent-text: #1a1a1a;
  --th-bg: #272b34;
  --selected-bg: #33302a;
  --input-bg: #1a1d23;
  --ok-bg: #163a2a;
  --ok-text: #6ee7a0;
  --bad-bg: #3d1f22;
  --bad-text: #fca5a5;
  --danger: #f87171;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --radius: 8px;
  --font-body: "Segoe UI", Arial, sans-serif;
  --font-head: "Segoe UI", Arial, sans-serif;
  color-scheme: dark;
}

/* ---------- Общие стили ---------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

h1 { font-family: var(--font-head); font-size: 24px; font-weight: 600; margin: 0 0 16px; }
h2 { font-family: var(--font-head); font-size: 18px; font-weight: 600; margin: 0 0 12px; }

a { color: var(--accent); }

/* ---------- Меню ---------- */

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}
.brand { padding: 0 16px 20px; }
.brand img {
  display: block;
  width: 100%;
  background: #ffffff;
  border-radius: var(--radius);
  padding: 10px 14px;
}

.menu { display: flex; flex-direction: column; }
.menu a {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 12px 20px;
  border-left: 4px solid transparent;
}
.menu a:hover { background: var(--sidebar-hover); }
.menu a.active { background: var(--sidebar-active); border-left-color: var(--sidebar-accent); }
.admin-menu { margin-top: 0; }

.userbox {
  padding: 16px 20px 0;
  border-top: 1px solid var(--sidebar-hover);
  margin-top: 24px;
  font-size: 14px;
}
.uname { font-weight: 600; }
.urole { opacity: 0.75; margin-bottom: 8px; }

.content { flex: 1; padding: 28px 32px; min-width: 0; }

/* ---------- Карточки и сетка ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; align-items: start; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px 20px;
}
.form-grid .wide { grid-column: 1 / -1; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 8px; margin: 4px 0; }
label.check input { width: 16px; height: 16px; }

/* ---------- Формы и кнопки ---------- */

input[type="text"], input[type="password"], input[type="date"], input[type="tel"],
input[type="search"], select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  color: var(--text);
  background: var(--input-bg);
}
textarea { resize: vertical; }

button, .button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { background: var(--accent-hover); }
button.link { background: none; color: var(--sidebar-text); padding: 0; text-decoration: underline; }
button.link:hover { background: none; }
button.link.danger { color: var(--danger); }

.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.actions-row { display: flex; gap: 16px; align-items: center; }

.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--border); }

.perms { display: flex; flex-wrap: wrap; gap: 6px 24px; }

.user-block { border-top: 1px solid var(--border); padding: 16px 0; }
.user-block:first-of-type { border-top: none; }
.password-form { margin-top: 12px; }

/* ---------- Выбор оформления ---------- */

.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.theme-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  background: var(--surface);
}
.theme-card:has(input:checked) { border-color: var(--accent); }
.theme-card input[type="radio"] { align-self: flex-start; }
.swatch {
  display: flex;
  height: 70px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}
.sw-side { width: 30%; background: var(--sidebar-bg); }
.sw-main { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.sw-card { flex: 1; background: var(--surface); border-radius: 4px; }
.sw-accent { height: 8px; width: 40%; background: var(--accent); border-radius: 4px; }

/* ---------- Таблицы ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--th-bg); font-weight: 600; font-size: 14px; }
tr.selected td { background: var(--selected-bg); }
td.wrap { max-width: 280px; white-space: pre-wrap; }
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort:hover { text-decoration: underline; }
th a.sort.active { color: var(--accent); font-weight: 700; }
.actions { white-space: nowrap; }
.actions form { display: inline; }
.actions a { margin-right: 10px; }

.tag { padding: 3px 8px; border-radius: 10px; font-size: 13px; }
.tag.ok { background: var(--ok-bg); color: var(--ok-text); }
.tag.no { background: var(--bad-bg); color: var(--bad-text); }
.tag.work { background: var(--selected-bg); color: var(--accent); }

.muted { color: var(--muted); }

.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { margin-bottom: 0; text-align: center; }
.stat-value { font-size: 28px; font-weight: 600; margin-top: 6px; }

dl.info { display: grid; grid-template-columns: 200px 1fr; gap: 10px 16px; margin: 0 0 20px; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }
dd.pre { white-space: pre-wrap; }

/* ---------- Сообщения и вход ---------- */

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.flash.success { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--bad-bg); color: var(--bad-text); }

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 340px;
  margin: 80px auto;
}
.login-logo { background: #ffffff; border-radius: var(--radius); padding: 14px; margin-bottom: 20px; }
.login-logo img { display: block; width: 100%; }
.login-box form { display: flex; flex-direction: column; gap: 14px; }
.login-box button { margin-top: 6px; }

@media (max-width: 900px) {
  .grid-2, .form-grid, .theme-options { grid-template-columns: 1fr; }
  body { flex-direction: column; }
  .sidebar { width: 100%; }
}

@media (max-width: 600px) {
  .orders-table th:not(:first-child),
  .orders-table td:not(:first-child) { display: none; }
  .orders-table td:first-child a { font-weight: 600; font-size: 16px; }
}
