:root {
  --bg: #f1f5f9;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #1d4ed8;
  --red: #dc2626;
  --green: #059669;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok { color: var(--green); font-weight: 600; }
.link {
  border: 0; background: none; color: var(--primary); cursor: pointer;
  font: inherit; padding: 0; text-decoration: none;
}
.link:hover { text-decoration: underline; }
.danger { color: var(--red); }
.primary {
  border: 0; background: var(--primary); color: #fff; border-radius: 8px;
  padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.primary:hover { filter: brightness(1.08); }

.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(135deg, #0f172a, #1e3a8a);
}
.login-card {
  background: var(--card); padding: 28px; border-radius: 16px; width: 100%;
  max-width: 360px; box-shadow: 0 20px 40px rgba(0, 0, 0, .25);
  display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { font-size: 20px; margin: 0; }
.login-card p { margin: 0; }
.login-card label, .modal-card label, .grid-form label {
  display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted);
}
input, select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; font: inherit; color: var(--text); background: #fff;
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
input[type=color] { padding: 2px; height: 38px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; }

header {
  background: #0f172a; color: #fff; padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { font-weight: 700; }
.user-box { display: flex; align-items: center; gap: 16px; }
.user-box .muted { color: #cbd5e1; }
.user-box .link { color: #dbeafe; }

main { max-width: 1100px; margin: 24px auto; padding: 0 16px; display: grid; gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 17px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
code { background: #f1f5f9; border-radius: 5px; padding: 2px 5px; font-size: 12px; }
.actions { white-space: nowrap; display: flex; gap: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }

.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-form .form-actions { grid-column: 1 / -1; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
label.check input { width: auto; }

.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 30px 16px;
}
.modal-card {
  background: var(--card); border-radius: 16px; padding: 22px; width: 100%; max-width: 480px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-card.wide { max-width: 720px; }
.modal-card h2 { margin: 0; font-size: 18px; }
.modal-actions { display: flex; align-items: center; gap: 14px; }

.toast {
  position: fixed; right: 20px; bottom: 20px; background: #0f172a; color: #fff;
  padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 25px rgba(0, 0, 0, .25); z-index: 100;
}
.toast.error { background: var(--red); }

@media (max-width: 700px) {
  header { flex-direction: column; align-items: flex-start; }
  .grid-form { grid-template-columns: 1fr; }
  .actions { flex-wrap: wrap; }
}
