/* ============================================================
   PurpleLane Team Portal — Design System
   ============================================================ */
:root {
  --brand-h: 262;
  --brand: hsl(262, 83%, 58%);          /* #7c3aed */
  --brand-strong: hsl(262, 83%, 50%);
  --brand-soft: hsl(262, 83%, 96%);
  --brand-grad: linear-gradient(135deg, hsl(262,83%,58%), hsl(292,76%,55%));

  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f3f2f9;
  --border: #e6e4f0;
  --text: #17151f;
  --text-2: #5b5871;
  --text-3: #928fa6;

  --success: #16a34a; --success-soft: #e8f7ee;
  --warning: #d97706; --warning-soft: #fdf3e3;
  --danger:  #dc2626; --danger-soft:  #fdecec;
  --info:    #2563eb; --info-soft:    #e9f0fd;
  --purple-soft: #f1ebfd;

  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(23,21,31,.05), 0 4px 16px rgba(23,21,31,.06);
  --shadow-lg: 0 8px 40px rgba(23,21,31,.14);
  --sidebar-w: 248px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
[data-theme="dark"] {
  --bg: #121118;
  --surface: #1a1823;
  --surface-2: #211f2d;
  --border: #2e2b3d;
  --text: #f0eef7;
  --text-2: #aaa7bd;
  --text-3: #6f6c84;
  --brand-soft: hsl(262, 40%, 20%);
  --success-soft: rgba(22,163,74,.16);
  --warning-soft: rgba(217,119,6,.16);
  --danger-soft: rgba(220,38,38,.16);
  --info-soft: rgba(37,99,235,.18);
  --purple-soft: rgba(124,58,237,.2);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.55;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
::selection { background: var(--brand); color: #fff; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; inset: 0 auto 0 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40; overflow-y: auto;
  transition: transform .25s ease;
}
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.content { padding: 24px 28px 60px; max-width: 1280px; width: 100%; margin: 0 auto; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand-grad);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 12px rgba(124,58,237,.35);
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.15; }
.brand-sub { font-size: 10.5px; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }

.nav { padding: 6px 10px 20px; flex: 1; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); padding: 14px 10px 5px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px; margin-bottom: 1px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav a .ico { width: 18px; text-align: center; opacity: .85; }
.nav a .count { margin-left: auto; background: var(--brand); color: #fff; font-size: 10.5px; padding: 1px 7px; border-radius: 99px; font-weight: 700; }

.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { font-size: 11.5px; color: var(--text-3); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 12px 28px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 16px;
  display: grid; place-items: center;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.icon-btn .dot {
  position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff;
  font-size: 10px; min-width: 17px; height: 17px; border-radius: 99px; display: grid; place-items: center; font-weight: 700; padding: 0 4px;
}
.hamburger { display: none; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 16px 20px; }
.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); }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }

/* ---------- Stat tiles ---------- */
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.stat .stat-label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.stat .stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.stat .stat-sub { font-size: 12px; color: var(--text-3); }
.stat .stat-value.brand { color: var(--brand); }
.stat .stat-value.ok { color: var(--success); }
.stat .stat-value.warn { color: var(--warning); }
.stat .stat-value.bad { color: var(--danger); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 2px 9px; font-size: 11.5px; font-weight: 600;
  border-radius: 99px; white-space: nowrap; line-height: 1.5;
  background: var(--surface-2); color: var(--text-2);
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-purple { background: var(--purple-soft); color: var(--brand); }
.badge-muted { background: var(--surface-2); color: var(--text-3); }

/* ---------- Progress ---------- */
.progress { position: relative; height: 18px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 90px; }
.progress-fill { height: 100%; border-radius: 99px; background: var(--brand-grad); transition: width .4s ease; }
.progress-fill.ok { background: linear-gradient(135deg,#16a34a,#4ade80); }
.progress-fill.mid { background: var(--brand-grad); }
.progress-fill.low { background: linear-gradient(135deg,#d97706,#fbbf24); }
.progress-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: var(--text); }
.progress.thin { height: 8px; } .progress.thin .progress-label { display: none; }

/* ---------- Stars ---------- */
.stars { display: inline-flex; gap: 1px; font-size: 15px; line-height: 1; }
.star { color: #d7d4e4; } [data-theme="dark"] .star { color: #3a3750; }
.star.full { color: #f5a623; }
.star.half { background: linear-gradient(90deg, #f5a623 50%, #d7d4e4 50%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.star-input { display: inline-flex; gap: 2px; }
.star-btn { background: none; border: 0; padding: 0 1px; font-size: 22px; line-height: 1; color: #d7d4e4; cursor: pointer; transition: transform .08s; }
[data-theme="dark"] .star-btn { color: #3a3750; }
.star-btn.on, .star-btn.hover { color: #f5a623; }
.star-btn:not(:disabled):hover { transform: scale(1.18); }
.star-btn:disabled { cursor: default; }

/* ---------- Avatars ---------- */
.avatar {
  --size: 32px;
  width: var(--size); height: var(--size); border-radius: 50%; flex-shrink: 0;
  display: inline-grid; place-items: center; font-weight: 700; font-size: calc(var(--size) * .38);
  color: #fff; background: hsl(var(--hue, 262), 55%, 52%);
}
.avatar-stack { display: flex; } .avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.userline { display: flex; align-items: center; gap: 10px; min-width: 0; }
.userline .nm { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userline .sub { font-size: 11.5px; color: var(--text-3); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
label.lbl { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin: 0 0 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea.input { resize: vertical; min-height: 84px; }
.field { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 16px; font: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  background: var(--brand); color: #fff; transition: filter .15s, transform .05s;
  text-decoration: none !important;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); filter: none; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); filter: none; color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-success { background: var(--success); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Flash ---------- */
.flash { padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13.5px; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.flash-info { background: var(--info-soft); color: var(--info); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(10,8,18,.55); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
  backdrop-filter: blur(3px);
}
.modal-back.open { display: flex; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; animation: pop .18s ease; border: 1px solid var(--border); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: ''; position: absolute; left: -21.5px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand); border: 2px solid var(--surface);
}
.tl-item.muted::before { background: var(--text-3); }
.tl-meta { font-size: 12px; color: var(--text-3); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.kanban-col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; }
.kanban-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 4px 6px 10px; display: flex; justify-content: space-between; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); font-size: 13px; }
.kanban-card .t { font-weight: 600; margin-bottom: 4px; }
.kanban-card .meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.muted { color: var(--text-3); } .small { font-size: 12.5px; }
.flex { display: flex; align-items: center; gap: 10px; } .flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); font-size: 13.5px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input { width: auto; min-width: 140px; }
.attachment-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; background: var(--surface-2); padding: 4px 10px; border-radius: 7px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent),
  radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #d946ef 12%, transparent), transparent),
  var(--bg); padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.login-brand .brand-logo { width: 52px; height: 52px; font-size: 22px; border-radius: 14px; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .hamburger { display: grid; }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 10px 16px; }
  .grid-2, .grid-3, .grid-4, .form-row, .form-row-3, .kanban { grid-template-columns: 1fr; }
}
.sidebar-overlay { display: none; }
@media (max-width: 820px) {
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
}
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main { margin: 0; }
}
