:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1c2430;
  --muted: #64748b;
  --line: #dbe2ea;
  --brand: #164e63;
  --brand-strong: #0e3a4a;
  --accent: #0f766e;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 17px; margin-bottom: 12px; }
h3 { font-size: 15px; }

.muted { color: var(--muted); margin: 4px 0 0; font-size: 13px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--brand);
  color: #fff;
}
.brand { color: #fff; font-weight: 700; letter-spacing: 0.04em; display: flex; align-items: baseline; gap: 8px; }
.brand span { font-size: 12px; font-weight: 400; opacity: 0.75; letter-spacing: 0.02em; }
.brand:hover { text-decoration: none; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions form { margin: 0; }
.topbar .btn-ghost { color: #e2e8f0; border-color: rgba(255, 255, 255, 0.35); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.user { font-size: 13px; opacity: 0.9; }

.layout { display: flex; min-height: calc(100vh - 56px); }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  padding: 18px 14px 40px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  max-height: calc(100vh - 56px);
  position: sticky;
  top: 0;
}
.sidebar-home {
  display: block;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--ink);
  border-radius: 6px;
  margin-bottom: 8px;
}
.sidebar-home:hover { background: var(--bg); text-decoration: none; }
.nav-group { margin-top: 16px; }
.nav-group-label {
  margin: 0 0 6px;
  padding: 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-group li a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
}
.nav-group li a:hover { background: var(--bg); text-decoration: none; }

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

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { text-decoration: none; background: #eef2f7; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.toolbar input[type="search"] {
  flex: 0 1 360px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  background: #f8fafc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: 0; }
td { max-width: 320px; overflow-wrap: anywhere; }
.actions { white-space: nowrap; }
.actions a { margin-right: 10px; font-size: 13px; }
.actions-head { width: 1%; }
.danger { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.pagination { display: flex; align-items: center; gap: 12px; margin-top: 16px; }

.messages { margin-bottom: 16px; }
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #bae6fd;
  background: #f0f9ff;
  font-size: 14px;
}
.alert-success { border-color: #bbf7d0; background: #f0fdf4; }
.alert-error, .alert-danger { border-color: #fecdca; background: var(--danger-bg); color: #7a271a; }
.alert ul { margin: 0; padding-left: 18px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.req { color: var(--danger); margin-left: 2px; }
.help { color: var(--muted); font-size: 12px; }
.error { margin: 0; color: var(--danger); font-size: 12px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }

.form-control, .form-select, input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="search"], input[type="date"], input[type="datetime-local"], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
.json-input { font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.form-control:focus, .form-select:focus, textarea:focus, select:focus, input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25);
  border-color: var(--accent);
}
select[multiple] { min-height: 160px; }
.form-check-input { width: 16px; height: 16px; }
.field-checkbox { flex-direction: row; align-items: center; gap: 10px; }
.field-checkbox label { order: 2; }

.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 720px;
}

.auth-wrap { display: flex; justify-content: center; padding-top: 40px; }
.auth-panel { width: 100%; max-width: 380px; }
.auth-panel .field { margin-top: 14px; }
.auth-panel .form-actions { margin-top: 22px; }

.group { margin-bottom: 28px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { margin-bottom: 2px; }
.card-actions { display: flex; gap: 8px; margin-top: 14px; }
.card-actions .btn { padding: 6px 10px; font-size: 13px; }

@media (max-width: 860px) {
  .layout { display: block; }
  .sidebar {
    width: auto;
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .content { padding: 20px 16px 40px; }
}
