:root {
  --bg: #faf7f2;
  --bg-accent: #fff3e6;
  --card-bg: #ffffff;
  --border: #e7e1d8;
  --text: #20221f;
  --muted: #74706a;
  --primary: #ea580c;
  --primary-dark: #c2410c;
  --primary-light: #fed7aa;
  --secondary: #0f766e;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(32, 24, 8, 0.06), 0 4px 16px rgba(32, 24, 8, 0.06);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at top, var(--bg-accent) 0%, var(--bg) 55%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

.view[hidden] { display: none; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  margin: 1.1rem auto;
  max-width: 720px;
}

h1 { font-size: 1.5rem; margin-top: 0; color: var(--primary-dark); }
h2 {
  font-size: 1.05rem;
  margin: 0 0 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
h2::before {
  content: "";
  width: 6px;
  height: 1.1em;
  border-radius: 3px;
  background: var(--primary);
  display: inline-block;
}

label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

input, select, button {
  font-size: 1rem;
  font-family: inherit;
}

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

button {
  cursor: pointer;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover { background: var(--primary-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

button.link-btn {
  background: none;
  color: var(--primary-dark);
  padding: 0.2rem 0.4rem;
  text-decoration: underline;
  font-weight: 600;
  border-radius: 4px;
}
button.link-btn:hover { background: var(--bg-accent); }
button.danger { background: var(--danger); }
button.danger:hover { background: #b91c1c; }
button.secondary { background: var(--secondary); }
button.secondary:hover { background: #115e59; }

.form-actions { display: flex; gap: 0.5rem; align-items: center; }

.login-card {
  margin-top: 4rem;
  border-top: 4px solid var(--primary);
}

.error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
}
.msg {
  color: var(--success);
  background: var(--success-bg);
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
}
.msg.error { color: var(--danger); background: var(--danger-bg); border-color: #fecaca; }

.banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #fcd34d;
  color: #78350f;
  padding: 0.7rem 1.1rem;
  margin: 0.9rem auto;
  max-width: 720px;
  border-radius: 10px;
  text-align: center;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(120deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 0.85rem 1.4rem;
  box-shadow: 0 2px 8px rgba(194, 65, 12, 0.25);
}
.topbar-title { font-weight: 800; letter-spacing: 0.01em; }
.topbar-user { display: flex; align-items: center; gap: 0.85rem; font-size: 0.9rem; }
.topbar-user .link-btn { color: white; opacity: 0.9; }
.topbar-user .link-btn:hover { background: rgba(255,255,255,0.15); opacity: 1; }

.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  padding: 0.6rem 1rem 0;
  max-width: 720px;
  margin: 0 auto;
}
.tab-btn {
  background: transparent;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
  padding: 0.55rem 0.9rem;
  white-space: nowrap;
  font-weight: 600;
}
.tab-btn:hover { background: var(--bg-accent); color: var(--primary-dark); }
.tab-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary); background: var(--bg-accent); font-weight: 800; }

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.4rem 0 0.75rem;
}
.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  background: white;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.checkbox-grid label:has(input:checked) {
  border-color: var(--primary);
  background: var(--bg-accent);
  color: var(--primary-dark);
  font-weight: 700;
}
.checkbox-grid input { width: auto; margin: 0; accent-color: var(--primary); }
.checkbox-grid label.inactive { opacity: 0.6; font-style: italic; }

.result {
  margin-top: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  background: var(--bg-accent);
  border: 1px solid var(--primary-light);
  min-height: 1.2rem;
}
.result strong { color: var(--primary-dark); }

.table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.03em; }
.table tbody tr:hover { background: var(--bg-accent); }

.inline-form { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.inline-form input { flex: 1; }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.2rem;
  border-bottom: 1px solid var(--border);
}
.list li:hover { background: var(--bg-accent); }

.name-inactive { color: var(--muted); font-style: italic; }

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}
.checkbox-inline input { width: auto; accent-color: var(--primary); }

.hint { color: var(--muted); font-size: 0.85rem; margin-top: -0.4rem; margin-bottom: 0.9rem; }

a { color: var(--primary-dark); }

code {
  background: var(--bg-accent);
  border: 1px solid var(--primary-light);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .card { margin: 0.6rem; padding: 1.1rem; }
  .topbar { padding: 0.65rem 0.9rem; }
  .tabs { padding: 0.4rem 0.6rem 0; }
}
