:root {
  --bg: #f5f1eb;
  --surface: #ffffff;
  --ink: #30251f;
  --muted: #756b63;
  --line: #ded6cc;
  --accent: #a65437;
  --accent-2: #bf946f;
  --brand-beige: #d8d1c7;
  --brand-dark: #6f3828;
  --danger: #9d2f2f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.public {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(166, 84, 55, .10), rgba(216, 209, 199, .62)),
    var(--bg);
}

.login-shell { width: min(440px, calc(100vw - 32px)); }
.login-panel, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(22, 32, 42, .06);
}
.login-panel { border-top: 6px solid var(--accent); }
.login-logo {
  display: block;
  width: min(300px, 100%);
  height: auto;
  margin: 0 0 22px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 284px 1fr;
}

.sidebar {
  background: #f7f2ec;
  color: var(--ink);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand { display: grid; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid #e1d7cd; }
.brand img {
  width: 180px;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}
.brand span { color: var(--muted); font-size: 13px; }
nav { display: grid; gap: 4px; }
nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 14px;
}
nav a:hover { background: rgba(166, 84, 55, .12); color: var(--brand-dark); }
.subnav {
  display: grid;
  gap: 2px;
  margin: -2px 0 6px 12px;
  padding-left: 10px;
  border-left: 2px solid #e1d7cd;
}
.subnav a {
  font-size: 13px;
  padding: 7px 9px;
}

.content {
  padding: 28px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 30px; }
h2 { font-size: 20px; margin-bottom: 14px; }
p { line-height: 1.5; }
.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 6px;
}
.muted, small { color: var(--muted); }
.alert {
  border: 1px solid #e8b5b5;
  color: var(--danger);
  background: #fff5f5;
  padding: 10px 12px;
  border-radius: 6px;
  margin: 16px 0;
}
.notice {
  border: 1px solid #b8d8c6;
  color: #1f5b3a;
  background: #f1fbf5;
  padding: 10px 12px;
  border-radius: 6px;
  margin: 16px 0;
}
.form-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}
.secret-box {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  padding: 12px;
  font-family: Consolas, Monaco, monospace;
  overflow-wrap: anywhere;
  margin: 10px 0 16px;
}
.secret-box.small { font-size: 12px; }

.stack, .grid-form { display: grid; gap: 14px; }
.grid-form { grid-template-columns: repeat(2, minmax(220px, 1fr)); align-items: end; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
}
textarea {
  min-height: 84px;
  resize: vertical;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.check { font-weight: 400; display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.check input { width: auto; }

button, .button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
}
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
button:hover, .button:hover { border-color: var(--accent-2); }
.primary:hover { background: #8f472e; border-color: #8f472e; }
button:disabled { opacity: .55; cursor: not-allowed; }
.ghost { background: #faf7f3; color: var(--muted); }

.summary, .cards, .shortcut-grid, .module-skeleton {
  display: grid;
  gap: 14px;
}
.summary { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
.summary div {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  padding: 16px;
  border-radius: 6px;
  display: grid;
  gap: 6px;
}
.cards { grid-template-columns: repeat(5, minmax(140px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 8px;
}
.card strong { font-size: 28px; }
.card span { color: var(--brand-dark); font-weight: 700; }
.shortcut-grid { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.shortcut-grid a, .module-skeleton span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  text-decoration: none;
  color: var(--ink);
  background: #fbfcfd;
}
.module-skeleton { grid-template-columns: repeat(5, minmax(120px, 1fr)); }

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}
.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 18px;
  align-content: space-between;
  min-height: 190px;
}
.admin-card h2 { margin-top: 10px; }
.admin-card p { color: var(--muted); margin-bottom: 0; }
.status-pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border: 1px solid #dfc6b5;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--brand-dark);
  background: #fff8f2;
  font-size: 12px;
  font-weight: 700;
}
.status-pill.secondary {
  background: #f5f1eb;
  border-color: var(--line);
  color: var(--muted);
  margin-left: 6px;
}
.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.panel-head p { margin-bottom: 0; }
.ticket-dashboard { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.filter-form .actions { align-self: end; }
.span-2 { grid-column: span 2; }
.ticket-list {
  display: grid;
  gap: 16px;
}
.ticket-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  display: grid;
  gap: 14px;
}
.ticket-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.ticket-head h3 {
  margin: 8px 0 4px;
  font-size: 18px;
  letter-spacing: 0;
}
.ticket-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}
.ticket-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.comment-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fbf9f6;
}
.history-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 18px;
}
details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-dark);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}
th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: middle;
}
th { color: var(--brand-dark); background: #f6f0ea; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.list-row:last-child { border-bottom: 0; }
.user-edit {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 1fr 1.5fr auto auto;
  gap: 12px;
  align-items: end;
}
.actions, .inline-action { display: inline-flex; gap: 8px; align-items: center; }
.inline-action { margin-top: 10px; justify-content: flex-end; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: auto; }
  .cards { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .shortcut-grid, .module-skeleton, .summary, .grid-form, .user-edit, .admin-grid, .ticket-dashboard, .ticket-form, .ticket-actions { grid-template-columns: 1fr; }
  .panel-head { display: grid; }
  .span-2 { grid-column: auto; }
}
