/* ── Reset & Base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary:     #2563eb;
  --color-primary-dk:  #1d4ed8;
  --color-danger:      #dc2626;
  --color-success:     #16a34a;
  --color-warning:     #d97706;
  --color-bg:          #f8fafc;
  --color-surface:     #ffffff;
  --color-border:      #e2e8f0;
  --color-text:        #1e293b;
  --color-text-muted:  #64748b;
  --color-sidebar-bg:  #1e293b;
  --color-sidebar-txt: #cbd5e1;
  --color-sidebar-act: #ffffff;
  --radius:            8px;
  --shadow:            0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:         0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --sidebar-w:         240px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

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

/* ── Layout ──────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  color: white;
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-icon { font-size: 22px; }

.sidebar-user {
  padding: 12px 16px;
  font-size: 12px;
  color: var(--color-sidebar-txt);
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-user strong { display: block; color: white; font-size: 13px; }

.nav-section {
  padding: 8px 0;
}

.nav-section-label {
  padding: 8px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
}

.nav-list { list-style: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--color-sidebar-txt);
  border-radius: 0;
  transition: background .15s, color .15s;
  cursor: pointer;
}

.nav-link:hover { background: rgba(255,255,255,.07); color: white; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,.12); color: white; font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-logout {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

/* ── Page Header ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}

.page-header p {
  color: var(--color-text-muted);
  margin-top: 2px;
  font-size: 13px;
}

/* ── Cards ───────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-clickable { cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.card-clickable:hover { box-shadow: var(--shadow-md); border-color: var(--color-primary); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.card-header h3 { font-size: 15px; font-weight: 600; }

.card-desc { font-size: 13px; color: var(--color-text-muted); margin-bottom: 10px; }

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 10px;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  line-height: 1.4;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dk); }

.btn-secondary { background: var(--color-border); color: var(--color-text); }
.btn-secondary:hover:not(:disabled) { background: #d1d5db; }

.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
}
.btn-danger-outline:hover:not(:disabled) { background: #fef2f2; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--color-border); color: var(--color-text); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────── */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }

.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s;
}

.input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.input::placeholder { color: #a0aec0; }
.input-sm { padding: 5px 8px; font-size: 13px; }

select.input { cursor: pointer; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-open      { background: #eff6ff; color: #1d4ed8; }
.badge-progress  { background: #fffbeb; color: #b45309; }
.badge-done      { background: #f0fdf4; color: #15803d; }
.badge-danger    { background: #fef2f2; color: #dc2626; font-weight: 600; }
.badge-info      { background: #f0f9ff; color: #0369a1; }
.badge-neutral   { background: #f3f4f6; color: #374151; }

/* ── Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td {
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
}

th {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Progress Bar ────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0 4px;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width .3s;
}

.progress-fill.done { background: var(--color-success); }

/* ── Checklist ───────────────────────────────────────── */
.checklist { display: flex; flex-direction: column; gap: 8px; }

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: background .1s;
}

.check-item.done { background: #f0fdf4; border-color: #bbf7d0; }

.check-toggle { flex-shrink: 0; margin-top: 1px; }
.check-toggle input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-primary); }

.check-content { flex: 1; }
.check-title { font-size: 14px; font-weight: 500; }
.check-item.done .check-title { text-decoration: line-through; color: var(--color-text-muted); }
.check-meta { font-size: 12px; color: var(--color-success); margin-top: 2px; }

/* ── Modal ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 25px rgba(0,0,0,.15);
}

.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 16px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.hidden { display: none !important; }

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state p { margin-bottom: 12px; }

/* ── Toast ───────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
  max-width: 320px;
}

.toast-success { background: #15803d; color: white; }
.toast-error   { background: var(--color-danger); color: white; }
.toast-info    { background: var(--color-primary); color: white; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Utility ─────────────────────────────────────────── */
.text-muted   { color: var(--color-text-muted); }
.text-error   { color: var(--color-danger); font-size: 13px; }
.text-success { color: var(--color-success); }
.mt-4  { margin-top: 16px; }
.mb-4  { margin-bottom: 16px; }
.back-link { font-size: 13px; color: var(--color-text-muted); }

/* ── Login Page ──────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 { font-size: 20px; font-weight: 700; margin-top: 8px; }
.login-logo p  { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }
.login-icon    { font-size: 40px; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .main-content { margin-left: 0; padding: 16px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}

/* ── Settings ────────────────────────────────────────── */
.settings-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.settings-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
}

.settings-section-header h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
}

.input-sm { padding: 4px 8px; font-size: 13px; height: auto; }

.form-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}
