/* ============================================================
   CTV Manager — Scandinavian Minimal Theme
   ============================================================ */

:root {
  --bg:          #F5F4F0;
  --surface:     #FFFFFF;
  --surface2:    #F0EFEB;
  --border:      #E2E0DA;
  --text:        #1A1A1A;
  --text-muted:  #6B6B6B;
  --text-light:  #9CA3AF;
  --primary:     #2D3748;
  --primary-h:   #1A202C;
  --accent-blue: #BFD7ED;
  --accent-pink: #F2D0D0;
  --accent-sage: #C8D8C8;
  --success:     #2D6A4F;
  --success-bg:  #D8F3DC;
  --warning:     #7B4F12;
  --warning-bg:  #FFF3CD;
  --danger:      #9B2335;
  --danger-bg:   #FDDDE6;
  --info:        #1A5276;
  --info-bg:     #D6EAF8;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --sidebar-w:   240px;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.sidebar-brand {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-icon { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: rgba(255,255,255,.5); }
.sidebar-actions { display: flex; gap: 8px; }
.btn-icon {
  padding: 6px 10px;
  background: rgba(255,255,255,.1);
  border-radius: var(--radius);
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 14px;
  transition: all .15s;
}
.btn-icon:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ── Page Header ── */
.page-header { margin-bottom: 28px; }
.page-title { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.page-subtitle { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--text); }

/* ── Stat Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: .15;
  transform: translate(20px, -20px);
}
.stat-card.blue::before  { background: var(--accent-blue); }
.stat-card.pink::before  { background: var(--accent-pink); }
.stat-card.sage::before  { background: var(--accent-sage); }
.stat-card.gold::before  { background: #F5CBA7; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); margin-top: 6px; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #f5c6cb; }
.btn-danger:hover { background: #f5c6cb; }
.btn-success { background: var(--success-bg); color: var(--success); border-color: #b7dfbf; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,55,72,.1); }
.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-gray    { background: var(--surface2);   color: var(--text-muted); }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: #b7dfbf; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: #f5c6cb; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #ffc107; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: #bee5eb; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  position: relative;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--text-muted);
}
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ── Login Page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.login-deco {
  position: absolute;
  border-radius: 50%;
  opacity: .25;
  pointer-events: none;
}
.login-deco-1 { width: 300px; height: 300px; background: var(--accent-blue);  top: -80px;  right: -60px; }
.login-deco-2 { width: 200px; height: 200px; background: var(--accent-pink);  bottom: -40px; left: -40px; }
.login-deco-3 { width: 120px; height: 120px; background: var(--accent-sage);  top: 40%;    left: 10%; }
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  margin-bottom: 12px;
}
.login-title { font-size: 22px; font-weight: 700; }
.login-sub { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }
.login-footer { text-align: center; font-size: 12px; color: var(--text-light); margin-top: 24px; }

/* ── Avatar ── */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface2);
  border: 2px solid var(--border);
}
.avatar-placeholder {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 15px;
}

/* ── Order Form ── */
.order-items-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.order-items-table th {
  padding: 8px 10px;
  background: var(--surface2);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.order-items-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.order-items-table td input,
.order-items-table td select { padding: 6px 8px; font-size: 13px; }
.order-total-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 16px;
}
.order-total-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13.5px; }
.order-total-row.grand { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; }
.order-total-row.commission { color: var(--success); font-weight: 600; }

/* ── Charts ── */
.chart-container { position: relative; height: 280px; }

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar label { font-size: 12px; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Utilities ── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.fw-600 { font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12.5px; }
.w-100 { width: 100%; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
