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

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --sidebar-bg: #111827;
  --sidebar-text: #d1d5db;
  --bg: #f3f4f6;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ─── Login ─────────────────────────────────────────────── */
.login-body {
  background: linear-gradient(135deg, #111827 0%, #1e40af 100%);
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.login-wrapper { width: 100%; max-width: 420px; padding: 20px; }
.login-card {
  background: var(--card); border-radius: 16px; padding: 40px 36px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-badge {
  width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 26px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(37,99,235,.4); margin-bottom: 12px;
}
.login-logo h1 { font-size: 22px; margin-bottom: 4px; }
.login-logo p { color: var(--text-muted); font-size: 12px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-error { background: #fef2f2; color: var(--danger); padding: 10px; border-radius: 8px; font-size: 13px; }
.login-hint { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 24px; }

/* ─── Layout ────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px; padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo-badge { width: 42px; height: 42px; font-size: 17px; margin-bottom: 0; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text span { font-size: 11px; color: #9ca3af; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-section { margin-bottom: 6px; }
.nav-section-title { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #6b7280; padding: 10px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none; cursor: pointer; font-size: 13px; margin-bottom: 2px;
  transition: background .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 15px; }
.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; flex-direction: column; margin-bottom: 10px; }
.sidebar-user strong { color: #fff; font-size: 13px; }
.sidebar-user span { font-size: 11px; color: #9ca3af; }

.main { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border); padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h2 { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { text-align: right; }
.topbar-user strong { display: block; font-size: 13px; }
.topbar-user span { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.content { padding: 24px; flex: 1; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; text-decoration: none;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); }
.btn-warning:hover { background: #b45309; }
.btn-ghost { background: transparent; color: var(--sidebar-text); border: 1px solid rgba(255,255,255,.2); }
.btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.icon-btn {
  background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted);
  position: relative; padding: 6px; border-radius: 8px; line-height: 1;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.notif-badge {
  position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff;
  border-radius: 50%; font-size: 10px; min-width: 16px; height: 16px; display: flex;
  align-items: center; justify-content: center; padding: 0 4px;
}

/* ─── Cards / grids ─────────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); padding: 18px; display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: #dcfce7; }
.stat-icon.orange { background: #ffedd5; }
.stat-icon.red { background: #fee2e2; }
.stat-icon.cyan { background: #cffafe; }
.stat-icon.purple { background: #ede9fe; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-muted); }

/* ─── Tables ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 10px 12px; background: #f9fafb; color: var(--text-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #f9fafb; }
td .actions { display: flex; gap: 6px; white-space: nowrap; }
.money { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge.blue { background: var(--primary-light); color: var(--primary-dark); }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.orange { background: #ffedd5; color: #b45309; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.gray { background: #f3f4f6; color: #374151; }
.badge.cyan { background: #cffafe; color: #0e7490; }
.badge.purple { background: #ede9fe; color: #6d28d9; }

.status-label { text-transform: capitalize; }

/* ─── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { min-height: 70px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 700px) { .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; } }

/* ─── Modal ────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto;
}
.modal {
  background: var(--card); border-radius: 14px; width: 100%; max-width: 680px;
  box-shadow: 0 24px 60px rgba(0,0,0,.3); animation: slideUp .2s ease;
}
.modal.wide { max-width: 900px; }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }

/* ─── Toast ────────────────────────────────────────────── */
.toast-area { position: fixed; top: 70px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #111827; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: slideUp .2s ease; max-width: 340px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

/* ─── Notifications panel ──────────────────────────────── */
.notif-panel {
  position: fixed; top: 64px; right: 24px; width: 360px; max-height: 480px; overflow-y: auto;
  background: var(--card); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.18);
  border: 1px solid var(--border); z-index: 90;
}
.notif-item { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: #f9fafb; }
.notif-item.unread { background: var(--primary-light); }
.notif-item h4 { font-size: 13px; margin-bottom: 2px; }
.notif-item p { font-size: 12px; color: var(--text-muted); }
.notif-item small { font-size: 11px; color: #9ca3af; }

/* ─── Misc ─────────────────────────────────────────────── */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; color: var(--text-muted); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--text-muted); padding: 40px 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mt-2 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-green { color: var(--success); }
.text-red { color: var(--danger); }
.text-right { text-align: right; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.chip { display: inline-block; padding: 2px 8px; background: #f3f4f6; border-radius: 6px; font-size: 12px; margin: 2px; }
.priority-high { color: var(--danger); font-weight: 600; }
.priority-normal { color: var(--text-muted); }
.priority-urgent { color: #7c3aed; font-weight: 700; }
.chart-bar { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding: 10px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart-bar-fill { width: 100%; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; transition: height .4s; }
.chart-bar-fill:hover { background: var(--primary-dark); }
.chart-label { font-size: 10px; color: var(--text-muted); }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 14px; }
.timeline-item::before {
  content: ''; position: absolute; left: -18px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary-light);
}
.timeline-item .time { font-size: 11px; color: var(--text-muted); }
.signature-box {
  border: 1px dashed var(--border); border-radius: 8px; padding: 14px; min-height: 70px;
  font-style: italic; color: var(--text-muted); background: #fafafa;
}
.kanban { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.kanban-col { background: #f9fafb; border-radius: 10px; border: 1px solid var(--border); padding: 12px; }
.kanban-col h4 { font-size: 12px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.kanban-card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .1s;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.kanban-card .kb-num { font-weight: 700; font-size: 13px; }
.kanban-card .kb-cust { font-size: 12px; color: var(--text-muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.stat-mini { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.stat-mini:last-child { border-bottom: none; }
