:root {
  --primary: #1a4d8f;
  --primary-dark: #0d2f5c;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #dbe1e8;
  --danger: #c0392b;
  --warning: #b8860b;
  --ok: #2e7d32;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: #1f2937;
}

.hidden { display: none !important; }

/* ---- Auth screens ---- */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.auth-card {
  background: var(--card);
  padding: 2.5rem;
  border-radius: 10px;
  width: 360px;
  max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.auth-card h1 { margin-top: 0; font-size: 1.4rem; color: var(--primary-dark); }
.auth-card label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.85rem; font-weight: 600; }
.auth-card input {
  width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem;
}
.auth-card button {
  margin-top: 1.25rem; width: 100%; padding: 0.6rem; background: var(--primary); color: white;
  border: none; border-radius: 6px; font-size: 0.95rem; cursor: pointer;
}
.auth-card button:hover { background: var(--primary-dark); }
.auth-card .link-btn {
  background: none; color: var(--primary); border: none; padding: 0; width: auto;
  margin: 0.5rem 0 0; text-decoration: underline; font-size: 0.85rem; cursor: pointer;
}
.error-text { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; }
.ok-text { color: var(--ok); font-size: 0.85rem; min-height: 1.2em; }

/* ---- App shell ---- */
#app-shell { display: flex; min-height: 100vh; }

#sidebar {
  width: 230px; flex-shrink: 0; background: var(--primary-dark); color: white; padding: 1rem 0;
}
#sidebar .brand { padding: 0 1rem 1rem; font-weight: 700; font-size: 1.1rem; border-bottom: 1px solid rgba(255,255,255,0.15); }
#sidebar .menu-group { padding: 0.75rem 0; }
#sidebar .menu-header { padding: 0.3rem 1rem; font-size: 0.75rem; text-transform: uppercase; opacity: 0.6; letter-spacing: 0.05em; }
#sidebar .menu-item {
  display: block; padding: 0.5rem 1rem; color: #d8e3f0; text-decoration: none; cursor: pointer; font-size: 0.9rem;
}
#sidebar .menu-item:hover { background: rgba(255,255,255,0.08); }
#sidebar .menu-item.active { background: var(--primary); color: white; font-weight: 600; }

#main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.5rem; background: white; border-bottom: 1px solid var(--border);
}
#topbar button { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.8rem; cursor: pointer; }

#content { padding: 1.5rem; overflow: auto; flex: 1; }

.box {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 1.25rem; margin-bottom: 1.25rem;
}
.box h2 { margin-top: 0; font-size: 1.05rem; color: var(--primary-dark); }
.box p.hint { color: #6b7280; font-size: 0.85rem; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > div { flex: 1; }

.progress-bar { width: 100%; height: 10px; border-radius: 5px; background: #e5e9f0; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); transition: width 0.3s ease; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data-table th, table.data-table td { border: 1px solid var(--border); padding: 0.4rem 0.55rem; text-align: left; }
table.data-table th { background: #eef2f7; }
table.data-table tr.selectable { cursor: pointer; }
table.data-table tr.selectable:hover { background: #f0f6ff; }
table.data-table tr.selected { background: #dbeafe; }
table.data-table td.expired { background: #fde2e1; }
table.data-table td.flag-true { background: #d7f2d7; }

button.btn { padding: 0.45rem 0.9rem; border-radius: 6px; border: 1px solid var(--primary); background: var(--primary); color: white; cursor: pointer; font-size: 0.85rem; }
button.btn:hover { background: var(--primary-dark); }
button.btn.secondary { background: white; color: var(--primary); }
button.btn.danger { background: white; color: var(--danger); border-color: var(--danger); }
button.btn.danger:hover { background: var(--danger); color: white; }
button.btn.warning { background: white; color: var(--warning); border-color: var(--warning); }

input[type=text], input[type=email], input[type=password], input[type=date], select {
  padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; width: 100%;
}

.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.2rem; }

.detail-value {
  padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: #f8f9fb;
  font-size: 0.9rem; min-height: 1.3em; overflow-wrap: anywhere; white-space: pre-wrap;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: white; border-radius: 8px; padding: 1.5rem; width: 420px; max-width: 92vw; max-height: 85vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.6rem 1rem; border-radius: 6px; color: white; font-size: 0.85rem; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.toast.message { background: var(--ok); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
