:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --border: #e3e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
.muted { color: var(--muted); font-weight: 400; }
h1 { font-size: 22px; margin: 0 0 4px; }
h3 { margin: 0 0 12px; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #0f172a; color: #e2e8f0; display: flex;
  flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px; font-size: 20px; font-weight: 700; }
.brand-icon { font-size: 24px; }
.brand-name { color: #fff; }
.nav { flex: 1; padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; padding: 14px 10px 4px; }
.nav-link {
  color: #cbd5e1; padding: 10px 12px; border-radius: 8px; display: block; font-weight: 500;
}
.nav-link:hover { background: #1e293b; color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link.logout { margin-top: 6px; color: #94a3b8; }
.sidebar-foot { padding: 12px; border-top: 1px solid #1e293b; }
.user-chip { padding: 8px 12px; margin-bottom: 6px; }
.user-chip-name { font-weight: 600; color: #fff; font-size: 13px; }
.user-chip-role { font-size: 11px; color: #64748b; }

.main { flex: 1; padding: 24px; }
.main-inner { max-width: 1200px; margin: 0 auto; }
.page-head { margin-bottom: 18px; }
.page-head .btn { margin-top: 10px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.card.empty { text-align: center; padding: 40px; color: var(--muted); }
.stat .stat-num { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat .stat-num.stat-money { color: var(--success); }
.stat .stat-label { color: var(--muted); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.actions { white-space: nowrap; }
.actions form { display: inline; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-draft { background: #e2e8f0; color: #475569; }
.badge-submitted { background: #dbeafe; color: #1d4ed8; }
.badge-approved { background: #dcfce7; color: #15803d; }
.badge-rejected { background: #fee2e2; color: #b91c1c; }
.badge-role-admin { background: #f1f5f9; color: #334155; }
.badge-role-pm { background: #ede9fe; color: #6d28d9; }
.badge-role-consultant { background: #ecfdf5; color: #047857; }

/* Buttons */
.btn {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-weight: 600; cursor: pointer; font-size: 13px;
  text-align: center; transition: .15s;
}
.btn:hover { background: #f1f5f9; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

/* Forms */
label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter-item label { margin-bottom: 4px; }
.filter-item input, .filter-item select { width: 170px; }
.filter-actions { display: flex; gap: 8px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.alert-success { background: #dcfce7; color: #15803d; }
.alert-error { background: #fee2e2; color: #b91c1c; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1d4ed8; }

/* Login */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.login-card { width: 380px; background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.login-logo { font-size: 44px; text-align: center; }
.login-card h1 { text-align: center; }
.login-card .muted { text-align: center; }
.login-card .hint { font-size: 12px; margin-top: 18px; }

/* Calendar */
.cal-scroll { overflow-x: auto; }
.cal-table { border-collapse: collapse; min-width: 900px; }
.cal-table th, .cal-table td { border: 1px solid var(--border); padding: 8px; text-align: center; min-width: 62px; }
.cal-table th { background: #f8fafc; }
.cal-table th.weekend, .cal-table td.weekend { background: #f1f5f9; }
.cal-table th.today, .cal-table td.today { background: #dbeafe; }
.cal-dow { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.cal-date { font-size: 12px; color: var(--text); font-weight: 600; }
.md-input { text-align: center; width: 100%; padding: 6px 2px; }
.note-input { width: 100%; padding: 4px 2px; font-size: 11px; margin-top: 4px; text-align: center; }
.md-read { font-weight: 700; font-size: 16px; padding: 6px 0; }
.note-read { font-size: 11px; }

/* Period row */
.period-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.period-select { flex: 1; min-width: 280px; }
.period-info { min-width: 240px; }
.period-nav { padding-bottom: 2px; }
.period-info.static strong { display: block; font-size: 15px; }
.summary-chip { float: right; font-size: 13px; color: var(--muted); }
.summary-chip strong { color: var(--primary); font-size: 16px; }

/* Form actions */
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 440px; max-width: 92vw; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-2 { grid-template-columns: 1fr; }
}
