/* ─── OLB CRM · Apple SaaS Design System ─────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg:           #f5f5f7;
  --surface:      #ffffff;
  --border:       #e5e5ea;
  --border-light: #f2f2f7;
  --text-primary: #1d1d1f;
  --text-secondary:#6e6e73;
  --text-tertiary: #aeaeb2;
  --accent:        #0071e3;
  --accent-hover:  #0077ed;
  --danger:        #ff3b30;
  --success:       #34c759;
  --warning:       #ff9f0a;
  --sidebar-w:     240px;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 16px rgba(0,0,0,.08);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ──────────────────────────────────────────────────────────── */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo .brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.3px;
}

.sidebar-logo .brand-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 12px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s ease;
  margin-bottom: 1px;
}

.nav-item:hover { background: var(--bg); color: var(--text-primary); }

.nav-item.active {
  background: rgba(0,113,227,.08);
  color: var(--accent);
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-user:hover { background: var(--bg); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}

.user-info .name  { font-size: 13px; font-weight: 600; }
.user-info .role  { font-size: 11px; color: var(--text-tertiary); }

/* ─── Main content ────────────────────────────────────────────────────── */

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 17px; font-weight: 600; letter-spacing: -.3px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

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

/* ─── Cards ───────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 0 22px 20px; }

/* ─── Stat cards ──────────────────────────────────────────────────────── */

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

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

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.8px;
  line-height: 1;
}

.stat-delta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ─── Tables ──────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background .1s;
}

tbody tr:hover { background: #fafafa; }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-muted { color: var(--text-secondary); }

/* ─── Badges / Status ─────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-blue    { background: rgba(0,113,227,.1);  color: #0071e3; }
.badge-green   { background: rgba(52,199,89,.1);  color: #25a244; }
.badge-orange  { background: rgba(255,159,10,.12); color: #b86a00; }
.badge-red     { background: rgba(255,59,48,.1);  color: #d70015; }
.badge-gray    { background: var(--border-light);  color: var(--text-secondary); }

/* ─── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-danger {
  background: rgba(255,59,48,.1);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(255,59,48,.18); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }

.btn svg { width: 14px; height: 14px; }

/* ─── Forms ───────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type=text],
input[type=email],
input[type=number],
input[type=password],
input[type=date],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}

textarea { resize: vertical; min-height: 100px; }

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

/* ─── Alert / Flash ───────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 18px;
}

.alert-error   { background: rgba(255,59,48,.08);   color: #c0392b; border: 1px solid rgba(255,59,48,.2); }
.alert-success { background: rgba(52,199,89,.08);   color: #1e7e34; border: 1px solid rgba(52,199,89,.2); }
.alert-info    { background: rgba(0,113,227,.06);   color: #0071e3; border: 1px solid rgba(0,113,227,.15); }

/* ─── Auth pages ──────────────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 48px 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.5px;
}

.auth-logo .logo-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.auth-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -.4px;
}

.auth-card p.sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

/* ─── Brand dot ───────────────────────────────────────────────────────── */

.brand-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ─── Pagination ──────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
}

.page-btn:hover { background: var(--bg); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── Divider ─────────────────────────────────────────────────────────── */

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

/* ─── Empty state ─────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-tertiary);
}

.empty-state svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 12px; }
.empty-state p   { font-size: 14px; }

/* ─── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar   { transform: translateX(-100%); }
  .main      { margin-left: 0; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content   { padding: 16px; }
}
