/* PLATES admin dashboard: the app's light look, calm type, dense tables. */

:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --raised: #edf1f5;
  --line: #dce2e8;
  --text: #0f1115;
  --muted: #536174;
  --subtle: #64748b;
  --accent: #253345;
  --soft: #e5edf6;
  --blue: #2563d9;
  --green: #247958;
  --green-soft: #e1f2e9;
  --red: #bc354a;
  --red-soft: #fbeff1;
  --amber: #93691f;
  --amber-soft: #fbf1da;
  --radius: 14px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 15px;
  font-weight: 600;
}

a {
  color: inherit;
}

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

.small {
  font-size: 12px;
}

.num {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand__mark {
  width: 24px;
  height: 24px;
}

.brand span {
  font-weight: 600;
  letter-spacing: 0.24em;
  font-size: 13px;
}

.brand em {
  font-style: normal;
  font-size: 12px;
  color: var(--subtle);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--raised);
}

/* Buttons and inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover {
  background: var(--raised);
}

.btn:active {
  transform: scale(0.98);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: default;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: #1b2634;
}

.btn--danger {
  color: var(--red);
}

.btn--danger:hover {
  background: var(--red-soft);
  border-color: #f1d3d8;
}

.btn--quiet {
  border-color: transparent;
  background: transparent;
}

.btn--small {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

input,
select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  min-width: 0;
}

input:focus,
select:focus {
  outline: none;
  border-color: #9db4d6;
  box-shadow: 0 0 0 3px rgba(37, 99, 217, 0.12);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  font-weight: 400;
  cursor: pointer;
}

.check input {
  height: auto;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Sign in */
.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.signin__card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px -30px rgba(15, 17, 21, 0.35);
}

.signin__card .brand {
  margin-bottom: 8px;
}

.signin__card .btn {
  height: 42px;
  margin-top: 4px;
}

.form-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}

/* Shell */
.shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.side .brand {
  padding: 0 8px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a {
  padding: 9px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
}

.nav a:hover {
  background: var(--raised);
  color: var(--text);
}

.nav a.on {
  background: var(--soft);
  color: var(--accent);
}

.side__foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 0 8px;
}

.side__foot p {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.main {
  padding: 28px clamp(16px, 3vw, 40px) 60px;
  min-width: 0;
  outline: none;
}

.head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.head p {
  margin-top: 4px;
}

.tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tools input[type="search"] {
  width: min(280px, 100%);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  padding: 16px;
}

.stat p:first-child {
  color: var(--muted);
  font-size: 12px;
}

.stat b {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.stat span {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--subtle);
}

.stat span.up {
  color: var(--green);
}

.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--raised);
}

.seg button {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 17, 21, 0.1);
}

/* Chart */
.chart {
  width: 100%;
  height: 180px;
  display: block;
}

.chart rect.bar {
  fill: var(--accent);
  transition: fill 0.15s;
}

.chart rect.bar:hover {
  fill: var(--blue);
}

.chart text {
  fill: var(--subtle);
  font-size: 10px;
}

.chart line {
  stroke: var(--raised);
}

.mini {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mini li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--raised);
}

.mini li:first-child {
  border-top: 0;
}

.mini li span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--raised);
  vertical-align: middle;
  white-space: nowrap;
}

th {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--subtle);
  background: #fafbfc;
  position: sticky;
  top: 0;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fafbfc;
}

td.wrap {
  white-space: normal;
  min-width: 220px;
}

td.actions {
  text-align: right;
}

td.actions .btn + .btn {
  margin-left: 6px;
}

tr.is-hidden td:not(.actions) {
  color: var(--subtle);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--raised);
  color: var(--muted);
}

.badge--green {
  background: var(--green-soft);
  color: var(--green);
}

.badge--amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge--blue {
  background: var(--soft);
  color: var(--accent);
}

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--raised);
  color: var(--muted);
  font-size: 12px;
}

.skeleton {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--raised), #f7f9fb, var(--raised));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

.notice {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #5e4312;
  margin-bottom: 16px;
}

/* Dialog */
.dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 30px 80px -20px rgba(15, 17, 21, 0.45);
}

.dialog::backdrop {
  background: rgba(15, 17, 21, 0.35);
}

.dialog form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
}

.dialog .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dialog .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chipbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  font-weight: 400;
}

.chipbox input {
  display: none;
}

.chipbox:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.dialog .buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Toasts */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 12px 30px -10px rgba(15, 17, 21, 0.5);
  animation: toast-in 0.25s ease-out;
}

.toast--error {
  background: var(--red);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* Small screens: navigation on top */
@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel__head {
    flex-wrap: wrap;
  }

  .side {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    order: 3;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
  }

  .side__foot {
    margin: 0 0 0 auto;
    flex-direction: row;
    align-items: center;
  }

  .side__foot p {
    display: none;
  }

  .grid2 {
    grid-template-columns: 1fr;
  }
}
