:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --ok: #059669;
  --error: #dc2626;
  --warn: #f59e0b;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --sidebar-bg: #111827;
  --sidebar-text: #d1d5db;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar .brand {
  padding: 20px;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 14px;
}

.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }

.sidebar .logout {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 { font-size: 18px; margin: 0; }
.topbar .who { color: var(--muted); font-size: 13px; }

.content { padding: 24px; flex: 1; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.card .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.card .value { font-size: 26px; font-weight: 700; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

.panel h2 { margin-top: 0; font-size: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:hover td { background: #f9fafb; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.ok { background: rgba(5, 150, 105, 0.12); color: var(--ok); }
.badge.error { background: rgba(220, 38, 38, 0.12); color: var(--error); }
.badge.warn { background: rgba(245, 158, 11, 0.14); color: #92400e; }
.badge.muted { background: #eef0f3; color: var(--muted); }

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--error); }
.btn.ok { background: var(--ok); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #111827;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
  max-width: 320px;
}
.toast.error { background: var(--error); }
.toast.ok { background: var(--ok); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a73e8, #111827);
}
.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.login-box h1 { margin-top: 0; font-size: 20px; }
.login-box .btn { width: 100%; margin-top: 8px; }
.login-error { color: var(--error); font-size: 13px; margin-top: 8px; min-height: 16px; }

.muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.text-right { text-align: right; }
