@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── Variables ─────────────────────────────────────────────────────────────── */

:root {
  --navy:        #1a2b4a;
  --navy-dark:   #111e35;
  --blue:        #0073e6;
  --blue-hover:  #005ec4;
  --blue-light:  #e8f2fd;
  --white:       #ffffff;
  --bg:          #f4f5f7;
  --bg-hover:    #eef0f3;
  --border:      #e5e7eb;
  --border-dark: #d1d5db;
  --text:        #111827;
  --text-2:      #6b7280;
  --text-3:      #9ca3af;
  --success:     #10b981;
  --success-bg:  #d1fae5;
  --error:       #ef4444;
  --error-bg:    #fee2e2;
  --warning:     #f59e0b;
  --warning-bg:  #fef3c7;
  --radius:      6px;
  --radius-lg:   10px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.1);
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --header-h:    56px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
h4 { font-size: .875rem; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App Header ─────────────────────────────────────────────────────────────── */

.app-header {
  height: var(--header-h);
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header .logo {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.02em;
  white-space: nowrap;
}

.app-header .logo span { color: #60a5fa; }

.header-spacer { flex: 1; }

.header-nav { display: flex; align-items: center; gap: .5rem; }

.header-badge {
  background: var(--error);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 0 5px;
  min-width: 18px;
  text-align: center;
  line-height: 18px;
  vertical-align: middle;
}

.header-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: rgba(255,255,255,.8);
  font-size: .875rem;
  cursor: pointer;
  padding: .375rem .625rem;
  border-radius: var(--radius);
  transition: background .15s;
}
.header-user:hover { background: rgba(255,255,255,.1); }
.header-user .avatar {
  width: 28px; height: 28px;
  background: var(--blue);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem .875rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.4;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }

.btn-secondary { background: var(--white); color: var(--text); border-color: var(--border-dark); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }

.btn-ghost     { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn-danger    { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-sm { padding: .3125rem .625rem; font-size: .8125rem; }
.btn-lg { padding: .625rem 1.25rem; font-size: 1rem; }

.btn-icon {
  padding: .375rem;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: .375rem; }

label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  font-family: var(--font);
  font-size: .875rem;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,115,230,.12);
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

textarea { resize: vertical; line-height: 1.6; }

input[type="color"] {
  padding: 2px 4px;
  width: 48px;
  height: 32px;
  cursor: pointer;
}

.form-row { display: flex; gap: .75rem; }
.form-row .form-group { flex: 1; }

.field-hint { font-size: .75rem; color: var(--text-2); }
.field-error { font-size: .75rem; color: var(--error); }

/* ─── Radio / Checkbox ───────────────────────────────────────────────────────── */

.radio-group, .check-group {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.radio-option, .check-option {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  cursor: pointer;
  font-size: .875rem;
  line-height: 1.4;
}

.radio-option input, .check-option input {
  width: auto;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}

/* ─── Badge / Chip ───────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .1875rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  line-height: 1.4;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ─── Tables ─────────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

th {
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .625rem .875rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: .625rem .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

tbody tr:hover { background: var(--bg); }

/* ─── Card ───────────────────────────────────────────────────────────────────── */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.card-body { padding: 1.25rem; }

/* ─── Section header ─────────────────────────────────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-title { font-size: 1rem; font-weight: 600; }

/* ─── Divider ────────────────────────────────────────────────────────────────── */

.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-lg { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title { font-size: 1rem; font-weight: 600; }

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  flex-shrink: 0;
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: .625rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  max-width: 360px;
}

.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { background: #059669; }
.toast--error   { background: var(--error); }
.toast--info    { background: #374151; }

/* ─── Loading / Spinner ──────────────────────────────────────────────────────── */

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}

.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 3rem 1rem;
  color: var(--text-2);
  font-size: .875rem;
}

/* ─── Empty state ────────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 3rem 1rem;
  color: var(--text-2);
  text-align: center;
}

.empty-state .empty-icon { font-size: 2.5rem; line-height: 1; }
.empty-state h3 { font-size: .9375rem; font-weight: 600; color: var(--text); }
.empty-state p  { font-size: .875rem; max-width: 280px; }

/* ─── Misc utilities ─────────────────────────────────────────────────────────── */

.hidden { display: none !important; }
.text-2 { color: var(--text-2); }
.text-sm { font-size: .8125rem; }
.text-xs { font-size: .75rem; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: .8125rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flag { color: var(--warning); }

.inline-flex { display: inline-flex; align-items: center; gap: .375rem; }

.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.mt-1  { margin-top: .25rem; }
.mt-2  { margin-top: .5rem; }
.mt-3  { margin-top: .75rem; }

/* ─── Alert banner ───────────────────────────────────────────────────────────── */

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: .625rem;
}

.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fcd34d; }
.alert-error   { background: var(--error-bg);   color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: var(--blue-light);  color: #1e40af; border: 1px solid #bfdbfe; }

/* ─── Login page ─────────────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
}

.login-logo h1 span { color: var(--blue); }

.login-logo p {
  font-size: .875rem;
  color: var(--text-2);
  margin-top: .25rem;
}

.login-form { display: flex; flex-direction: column; gap: 1rem; }

.login-error {
  background: var(--error-bg);
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: .625rem .875rem;
  border-radius: var(--radius);
  font-size: .875rem;
}
