:root {
  --bg: #0d0d12;
  --sidebar: #13131a;
  --card: #1a1a24;
  --card2: #1f1f2e;
  --border: #2a2a3a;
  --text: #e2e2f0;
  --text-muted: #7878a0;
  --accent: #6366f1;
  --accent-hover: #4f52e0;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  display: flex;
}

/* Sidebar */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.3px;
}

.sidebar-logo span { color: var(--text-muted); font-weight: 400; }

.sidebar-section {
  padding: 8px 8px 0;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 16px;
  padding-left: 16px;
}

.sidebar-nav { flex: 1; padding: 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  margin-bottom: 2px;
  font-weight: 500;
  text-decoration: none;
}

.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-rates {
  padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.rate-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.rate-row span:last-child { color: var(--text); font-weight: 600; }

.rate-update-btn {
  margin-top: 8px;
  width: 100%;
  padding: 5px;
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s;
}

.rate-update-btn:hover { color: var(--text); border-color: var(--accent); }

/* Main */
.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--sidebar);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 18px; font-weight: 700; }

.content { padding: 24px; }

/* Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .label { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 26px; font-weight: 700; }
.stat-card .sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.stat-card.green .value { color: var(--success); }
.stat-card.red .value { color: var(--danger); }
.stat-card.yellow .value { color: var(--warning); }
.stat-card.blue .value { color: var(--info); }

/* Tables */
.table-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.table-title { font-weight: 600; font-size: 15px; }

table { width: 100%; border-collapse: collapse; }

th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-weight: 600;
  background: rgba(0,0,0,0.2);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}

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

tr.row-active td { background: rgba(34,197,94,0.03); }
tr.row-expiring td { background: rgba(245,158,11,0.05); }
tr.row-expired td { background: rgba(239,68,68,0.03); }

tr.row-active:hover td { background: rgba(34,197,94,0.07); }
tr.row-expiring:hover td { background: rgba(245,158,11,0.09); }
tr.row-expired:hover td { background: rgba(239,68,68,0.07); }

tr.row-active td:first-child { border-left: 3px solid var(--success); }
tr.row-expiring td:first-child { border-left: 3px solid var(--warning); }
tr.row-expired td:first-child { border-left: 3px solid rgba(239,68,68,0.4); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge::before { content: '●'; font-size: 7px; }
.badge.active { background: rgba(34,197,94,0.15); color: var(--success); border: 1px solid rgba(34,197,94,0.25); }
.badge.expiring { background: rgba(245,158,11,0.15); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.badge.expired { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-success { background: rgba(34,197,94,0.15); color: var(--success); }
.btn-success:hover { background: rgba(34,197,94,0.25); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.btn-warning:hover { background: rgba(245,158,11,0.25); }

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s;
}

.filter-btn:hover, .filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Forms / Inputs */
.input, select.input {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.input:focus, select.input:focus { border-color: var(--accent); }
select.input option { background: var(--card2); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Days remaining indicator */
.days-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.days-chip.ok { background: rgba(34,197,94,0.15); color: var(--success); }
.days-chip.warn { background: rgba(245,158,11,0.18); color: var(--warning); }
.days-chip.bad { background: rgba(239,68,68,0.12); color: #f87171; }

/* Client card */
.client-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.client-card:hover { border-color: var(--accent); transform: translateY(-1px); }

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title { font-size: 20px; font-weight: 700; }

/* Alert box */
.alert-box {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.alert-box .alert-title { color: var(--warning); font-weight: 600; margin-bottom: 10px; font-size: 13px; }
.alert-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 13px; }
.alert-item:last-child { border-bottom: none; }

/* Empty state */
.empty-state { text-align: center; padding: 48px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

/* Loading */
.loading { text-align: center; padding: 32px; color: var(--text-muted); }

/* Action buttons cell */
.actions { display: flex; gap: 4px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.info { background: var(--accent); color: #fff; }

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

/* Month chart bars */
.chart-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}

.chart-bar-label { width: 60px; color: var(--text-muted); text-align: right; }
.chart-bar-wrap { flex: 1; background: var(--card2); border-radius: 3px; height: 20px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.5s ease; display: flex; align-items: center; padding-left: 8px; font-size: 11px; color: rgba(255,255,255,0.8); white-space: nowrap; min-width: 2px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* Kanban */
.kanban-wrap {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
  min-height: calc(100vh - 140px);
}

.kanban-col {
  min-width: 280px;
  max-width: 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 140px);
}

.kanban-col-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
}

.kanban-col-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kanban-col-name {
  font-weight: 700;
  font-size: 13px;
  flex: 1;
}

.kanban-col-count {
  background: var(--card2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.kanban-col-menu {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.kanban-col-menu:hover { background: var(--card2); color: var(--text); }

.kanban-tasks {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.kanban-tasks.drag-over { background: rgba(99,102,241,0.07); border-radius: 6px; }

.task-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  position: relative;
}

.task-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.task-card.priority-high { border-left-color: var(--danger); }
.task-card.priority-medium { border-left-color: var(--warning); }
.task-card.priority-low { border-left-color: var(--text-muted); }
.task-card.done { opacity: 0.5; }
.task-card.done .task-title { text-decoration: line-through; }
.task-card.dragging { opacity: 0.4; }

.task-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.task-check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: all 0.15s;
}

.task-check:hover { border-color: var(--success); }
.task-check.checked { background: var(--success); border-color: var(--success); }
.task-check.checked::after { content: '✓'; font-size: 11px; color: #fff; font-weight: 700; }

.task-num { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.task-title { font-size: 13px; font-weight: 500; line-height: 1.4; flex: 1; }
.task-desc { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }

.task-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.priority-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.priority-badge.high { background: rgba(239,68,68,0.15); color: var(--danger); }
.priority-badge.medium { background: rgba(245,158,11,0.15); color: var(--warning); }
.priority-badge.low { background: rgba(120,120,160,0.15); color: var(--text-muted); }

.task-due {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

.task-due.overdue { color: var(--danger); }
.task-due.soon { color: var(--warning); }

.kanban-add-btn {
  margin: 0 10px 10px;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  transition: all 0.15s;
  width: calc(100% - 20px);
}

.kanban-add-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,0.05); }

.kanban-new-col {
  min-width: 280px;
  max-width: 280px;
}

.kanban-new-col-btn {
  width: 100%;
  padding: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  text-align: center;
}

.kanban-new-col-btn:hover { border-color: var(--accent); color: var(--accent); }

.color-picker-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.color-dot:hover, .color-dot.selected { border-color: #fff; transform: scale(1.15); }

/* Item 11: drag position indicators */
.task-card.drag-top { border-top: 3px solid var(--accent) !important; margin-top: -1px; }
.task-card.drag-bottom { border-bottom: 3px solid var(--accent) !important; }
