/* =========================================================
   Agency OS — clean, minimal design system
   ========================================================= */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e6e8f0;
  --text: #1a1d29;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --primary: #5b6bff;
  --primary-dark: #4552d6;
  --primary-light: #eef0ff;
  --success: #1a9e6b;
  --success-light: #e6f7f0;
  --warning: #b8860b;
  --warning-light: #fff6e0;
  --danger: #d64545;
  --danger-light: #fdecec;
  --info: #2d78c9;
  --info-light: #eaf3fc;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .08);
  --sidebar-w: 224px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Layout ---------- */

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

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

.sidebar-brand {
  padding: 20px 20px 16px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-muted); font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--bg); color: var(--text); }
.sidebar-nav a.active { background: var(--primary-light); color: var(--primary-dark); }
.sidebar-nav .nav-icon { width: 17px; text-align: center; opacity: .85; }
.sidebar-section-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); padding: 14px 12px 6px;
}

.sidebar-footer {
  padding: 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.sidebar-footer .avatar { width: 30px; height: 30px; font-size: 12px; }
.sidebar-footer .who { flex: 1; min-width: 0; }
.sidebar-footer .who .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .who .role { font-size: 11.5px; color: var(--text-faint); }
.sidebar-footer .logout { color: var(--text-faint); font-size: 16px; padding: 4px 6px; border-radius: 6px; }
.sidebar-footer .logout:hover { background: var(--bg); color: var(--danger); }

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 60px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.topbar h1 { font-size: 20px; }
.topbar .sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- 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; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b93a3a; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / surfaces ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 14.5px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat-card { padding: 16px 18px; }
.stat-card .stat-num { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.stat-card.accent-danger .stat-num { color: var(--danger); }
.stat-card.accent-warning .stat-num { color: var(--warning); }
.stat-card.accent-success .stat-num { color: var(--success); }
.stat-card.accent-primary .stat-num { color: var(--primary); }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px;
  white-space: nowrap;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-info    { background: var(--info-light); color: var(--info); }
.badge-neutral { background: var(--primary-light); color: var(--primary-dark); }
.badge-muted   { background: #f1f2f6; color: var(--text-muted); }

/* ---------- Avatars ---------- */

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0;
}

/* ---------- Task list rows ---------- */

.task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s ease;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--bg); }
.task-row .task-main { flex: 1; min-width: 0; }
.task-row .task-title { font-weight: 600; font-size: 13.5px; margin-bottom: 2px; }
.task-row .task-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 8px; align-items: center; }
.task-row .task-due { font-size: 12px; color: var(--text-muted); min-width: 90px; text-align: right; }
.task-row .task-due.overdue { color: var(--danger); font-weight: 600; }

/* ---------- Table ---------- */

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); padding: 10px 14px; border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--bg); }

/* ---------- Forms ---------- */

label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local],
input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13.5px; background: var(--surface); color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-group { margin-bottom: 14px; }
.form-row { display: flex; gap: 14px; }
.form-row > * { flex: 1; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(16, 20, 30, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; z-index: 1000; overflow-y: auto;
}
.hidden { display: none !important; }
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%;
  max-width: 560px; box-shadow: var(--shadow-md); overflow: hidden;
}
.modal.modal-lg { max-width: 780px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-faint); cursor: pointer; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Misc ---------- */

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  border-radius: 20px; background: var(--bg); font-size: 12px; font-weight: 500; color: var(--text-muted);
}
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: var(--shadow-md); animation: fadein .15s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #f6f7fb 0%, #eef0ff 100%);
}
.login-card { width: 100%; max-width: 380px; padding: 34px 30px; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; margin-right: 6px; }
.login-brand .name { font-size: 19px; font-weight: 700; }
.login-brand .tag { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.login-error { background: var(--danger-light); color: var(--danger); padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 14px; }
.demo-hint { margin-top: 16px; font-size: 11.5px; color: var(--text-faint); text-align: center; line-height: 1.6; }

.handoff-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.handoff-item:last-child { border-bottom: none; }

.timeline-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .t-icon { width: 22px; height: 22px; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -240px; z-index: 900; transition: left .2s ease; }
  .sidebar.open { left: 0; }
  .main { padding: 16px; }
  .mobile-menu-btn { display: inline-flex; }
}
.mobile-menu-btn { display: none; }
