/* ============================================================
   Company Portal — base stylesheet (self-contained, no CDNs)
   ============================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e4e8f0;
  --text: #1f2933;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.12);
  --sidebar-w: 240px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: #111827;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar .brand {
  font-weight: 700; color: #fff; font-size: 1.15rem;
  padding: 1.15rem 1.25rem; display: flex; align-items: center; gap: .5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar nav { padding: .75rem; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: #cbd5e1; padding: .6rem .75rem; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: .65rem; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: .9rem .75rem .3rem; }
.sidebar .side-foot { padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .82rem; }
.sidebar .side-foot .who { color: #fff; font-weight: 600; }
.sidebar .side-foot a { color: #93c5fd; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 30;
}
.topbar .page-title { font-weight: 600; font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
.hamburger { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text); }
.content { padding: 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---------- Notification bell ---------- */
.bell { position: relative; }
.bell-btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 50%;
  width: 40px; height: 40px; font-size: 1.15rem; cursor: pointer; display: grid; place-items: center;
}
.bell-badge {
  position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff;
  border-radius: 999px; font-size: .68rem; font-weight: 700; min-width: 18px; height: 18px;
  display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface);
}
.bell-menu {
  position: absolute; right: 0; top: 48px; width: 360px; max-width: 90vw; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden; display: none;
}
.bell-menu.open { display: block; }
.bell-menu header { padding: .75rem 1rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.bell-menu .n-list { max-height: 400px; overflow-y: auto; }
.n-item { padding: .7rem 1rem; border-bottom: 1px solid var(--border); display: block; color: var(--text); }
.n-item:hover { background: var(--surface-2); text-decoration: none; }
.n-item.unread { background: var(--primary-soft); }
.n-item .n-msg { font-size: .9rem; }
.n-item .n-time { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.n-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-body { padding: 1.1rem 1.25rem; }
.card .card-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Stat tiles ---------- */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.stat .value { font-size: 2rem; font-weight: 700; margin-top: .2rem; }
.stat .value.warn { color: var(--warning); }
.stat .value.bad { color: var(--danger); }
.stat .value.ok { color: var(--success); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; border: 1px solid transparent;
  background: var(--primary); color: #fff; padding: .5rem .9rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none; line-height: 1;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: .35rem .6rem; font-size: .8rem; }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700;
  padding: .22rem .55rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.badge.gray   { background: #f1f5f9; color: #475569; }
.badge.blue   { background: #e0f2fe; color: #0369a1; }
.badge.indigo { background: #e0e7ff; color: #4338ca; }
.badge.green  { background: #dcfce7; color: #15803d; }
.badge.amber  { background: #fef3c7; color: #b45309; }
.badge.red    { background: #fee2e2; color: #b91c1c; }
.badge.purple { background: #f3e8ff; color: #7e22ce; }
.badge.dot::before { content: "●"; font-size: .6rem; }

.prio-low    { background: #f1f5f9; color: #475569; }
.prio-medium { background: #e0f2fe; color: #0369a1; }
.prio-high   { background: #fef3c7; color: #b45309; }
.prio-urgent { background: #fee2e2; color: #b91c1c; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.data tbody tr:hover { background: var(--surface-2); }

/* ---------- Forms ---------- */
form .field { margin-bottom: 1rem; }
form label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
form input[type=text], form input[type=email], form input[type=tel], form input[type=date],
form input[type=password], form input[type=number], form select, form textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; background: var(--surface); color: var(--text);
}
form textarea { min-height: 110px; resize: vertical; }
form input:focus, form select:focus, form textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
form select[multiple] { min-height: 120px; }
.help { color: var(--muted); font-size: .8rem; margin-top: .25rem; }

/* Checkbox pills (multi-select replacement for assignees/tags) */
div.pill-options { display: flex; flex-wrap: wrap; gap: .5rem; }
div.pill-options > div { margin: 0; }
.pill-options label {
  display: inline-flex; align-items: center; gap: .45rem; margin: 0;
  border: 1px solid var(--border); border-radius: 999px;
  padding: .42rem .85rem; cursor: pointer; user-select: none;
  background: var(--surface); font-weight: 500; font-size: .88rem;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.pill-options label:hover { border-color: var(--primary); background: var(--primary-soft); }
.pill-options input[type=checkbox] {
  margin: 0; width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer;
}
.pill-options label:has(input:checked) {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.pill-options label:has(input:checked):hover { background: var(--primary-dark); }
.pill-options label:has(input:checked) input[type=checkbox] { accent-color: #fff; }
.pill-options label:focus-within { outline: 2px solid var(--primary-soft); outline-offset: 1px; }
.errorlist { color: var(--danger); font-size: .82rem; margin: .25rem 0 0; padding-left: 1rem; }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; }

/* ---------- Messages ---------- */
.messages { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.alert { padding: .7rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: .9rem; }
.alert.success { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.alert.danger  { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.alert.warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.alert.info    { background: #e0f2fe; border-color: #bae6fd; color: #075985; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.inline { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff;
  display: inline-grid; place-items: center; font-size: .78rem; font-weight: 700; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: var(--success); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }
.breadcrumb a { color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.tag-chip { font-size: .72rem; background: var(--surface-2); border: 1px solid var(--border); padding: .12rem .5rem; border-radius: 999px; color: var(--muted); }

/* ---------- Kanban board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 1rem; align-items: start; }
.board .col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; }
.board .col h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; justify-content: space-between; padding: .3rem .4rem; }
.board .col .cards { display: flex; flex-direction: column; gap: .55rem; }
.tcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .65rem .7rem; box-shadow: var(--shadow); }
.tcard a { color: var(--text); font-weight: 600; font-size: .9rem; }
.tcard .meta { display: flex; justify-content: space-between; align-items: center; margin-top: .5rem; }

/* ---------- Public site ---------- */
.public-wrap { max-width: 720px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.public-hero { text-align: center; padding: 2.5rem 1rem 1.5rem; }
.public-hero h1 { font-size: 2rem; }
.public-nav { background: var(--surface); border-bottom: 1px solid var(--border); padding: .9rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; }
.public-nav .brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  body.nav-open .scrim { display: block; }
}
