/* ============================================================
   BRØNDAY — app shell & shared UI (dark theme, monday-like)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
.icon { fill: currentColor; flex: none; vertical-align: middle; }

/* ---------------- auth pages ---------------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; overflow: auto; }
.auth-card { width: 100%; max-width: 400px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; padding: 34px 32px; }
.auth-logo { font-size: 26px; font-weight: 800; letter-spacing: .5px; text-align: center; margin-bottom: 22px; }
.auth-logo span { color: var(--accent); }
.auth-title { font-size: 18px; margin: 0 0 4px; }
.auth-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 16px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; }
.flabel { display: block; font-size: 12px; color: var(--text-muted); margin: 14px 0 5px; }
.finput, .fselect, textarea.finput {
  width: 100%; padding: 9px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit;
}
.finput:focus, .fselect:focus { outline: none; border-color: var(--accent); }
.code-input { text-align: center; letter-spacing: 8px; font-size: 20px; font-weight: 700; }
.fcheck { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin: 12px 0; }
.form-err { background: rgba(226,68,92,.14); border: 1px solid var(--danger); color: #ffb3bd; padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 10px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px;
  background: var(--bg-hover); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .12s;
}
.btn:hover { background: var(--border); }
.btn.primary { background: var(--btn-primary); border-color: var(--btn-primary); color: var(--btn-primary-text); }
.btn.primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; margin-top: 18px; }
.btn[disabled] { opacity: .45; cursor: default; }

/* ---------------- icon rail ---------------- */
.rail {
  position: fixed; inset: 0 auto 0 0; width: 64px; z-index: 60;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px;
}
.rail-logo { font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 14px; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; }
.rail-logo span { color: var(--accent); }
.rail-logo img { display: block; }
.rail-btn {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 9px; color: var(--text-muted);
}
.rail-btn:hover { background: var(--bg-hover); color: var(--text); }
.rail-btn.on { background: rgba(87,155,252,.16); color: var(--accent); }
.rail-badge {
  position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: #fff; border-radius: 8px; font-size: 10px; font-style: normal;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.rail-spacer { flex: 1; }
.rail-user .avatar { border: 2px solid transparent; }
.rail-user:hover .avatar { border-color: var(--accent); }

/* ---------------- sidebar ---------------- */
.sidebar {
  position: fixed; inset: 0 auto 0 64px; width: 260px; z-index: 50;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.ws-switcher { padding: 12px 12px 8px; position: relative; }
.ws-current {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  cursor: pointer; font-weight: 600; font-size: 14px;
}
.ws-current:hover { background: var(--bg-hover); }
.ws-swatch {
  width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex: none;
}
.ws-swatch.sm { width: 20px; height: 20px; font-size: 9px; border-radius: 5px; }
.ws-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-menu {
  position: absolute; top: 100%; left: 12px; right: 12px; z-index: 70;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.5); max-height: 300px; overflow: auto;
}
.ws-menu-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--text); font-size: 13px; cursor: pointer; width: 100%;
  background: none; border: 0; text-align: left;
}
.ws-menu-item:hover { background: var(--bg-hover); }
.ws-add { color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; border-radius: 0 0 7px 7px; }

.sidebar-actions { padding: 4px 12px 10px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--border); }
.sidebar-search {
  padding: 7px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
  color: var(--text); font-size: 13px;
}
.sidebar-search:focus { outline: none; border-color: var(--accent); }
.sidebar-boards { flex: 1; overflow-y: auto; padding: 8px; }
.sb-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px;
  color: var(--text); font-size: 13px; cursor: pointer; position: relative;
}
.sb-item:hover { background: var(--bg-hover); }
.sb-item.on { background: rgba(87,155,252,.14); color: #fff; }
.sb-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sb-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-item .sb-pin { opacity: 0; color: var(--text-muted); }
.sb-item:hover .sb-pin { opacity: 1; }
.sb-item .sb-pin.pinned { opacity: 1; color: var(--warning); }
.sb-section { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); padding: 10px 10px 5px; }
.sidebar-footer { padding: 10px 12px; border-top: 1px solid var(--border); }
.sidebar-logout { display: flex; gap: 8px; align-items: center; width: 100%; background: none; border: 0; color: var(--text-muted); font-size: 13px; cursor: pointer; padding: 6px; border-radius: 7px; }
.sidebar-logout:hover { background: var(--bg-hover); color: var(--text); }

/* ---------------- main / topbar ---------------- */
.main { margin-left: 324px; height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 52px; flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.topbar-burger { display: none; background: none; border: 0; color: var(--text); cursor: pointer; }
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.presence-stack { display: flex; }
.presence-stack .avatar { margin-left: -7px; border: 2px solid var(--bg); }
.presence-stack .avatar:first-child { margin-left: 0; }
.content { flex: 1; overflow: auto; padding: 24px 28px; }

.avatar {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; flex: none; object-fit: cover; background: var(--bg-hover);
}

/* ---------------- generic page bits ---------------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .spacer { flex: 1; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; cursor: pointer; transition: transform .12s, border-color .12s; position: relative;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .card-color { position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: 12px 12px 0 0; }
.card h3 { margin: 6px 0 4px; font-size: 15px; }
.card .muted { color: var(--text-muted); font-size: 12px; }
.muted { color: var(--text-muted); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-muted); margin: 26px 0 12px; }

/* tables (generic, non-board) */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 9px 12px; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--border); font-size: 12px; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: var(--bg-hover); }

/* toasts */
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-panel); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 11px 18px; border-radius: 9px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
  animation: toast-in .2s ease;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* modal */
.modal-root:empty { display: none; }
.modal-root {
  position: fixed; inset: 0; z-index: 150; background: rgba(5,7,12,.6);
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; overflow: auto;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 480px; padding: 24px; animation: toast-in .18s ease;
}
.modal.wide { max-width: 720px; }
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* popover */
.popover-root { position: fixed; inset: 0; z-index: 140; pointer-events: none; }
.popover-root > * { pointer-events: auto; }
.popover {
  position: absolute; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.55); padding: 8px; min-width: 180px;
}
.popover .pop-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 6px;
  font-size: 13px; cursor: pointer; color: var(--text); white-space: nowrap; width: 100%;
  background: none; border: 0; text-align: left;
}
.popover .pop-item:hover { background: var(--bg-hover); }
.popover .pop-sep { border-top: 1px solid var(--border); margin: 6px 4px; }
.popover .pop-head { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; padding: 6px 10px 4px; }

/* color palette picker */
.color-grid { display: grid; grid-template-columns: repeat(6, 28px); gap: 8px; padding: 8px; }
.color-dot { width: 28px; height: 28px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.color-dot.on { border-color: #fff; }
.cp-custom { display: flex; gap: 8px; padding: 4px 8px 8px; align-items: center; }
.cp-custom input[type="color"] { width: 34px; height: 28px; border: 0; background: none; cursor: pointer; padding: 0; }
.cp-custom .finput { flex: 1; padding: 5px 8px; font-size: 12px; font-family: monospace; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 34px); gap: 6px; padding: 8px; max-height: 264px; overflow-y: auto; }
.icon-cell { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 8px; cursor: pointer; color: var(--text-muted); }
.icon-cell:hover { background: var(--bg-hover); color: var(--text); }
.icon-cell.on { background: rgba(87,155,252,.16); color: var(--accent); }
.sb-bicon { display: flex; flex: none; align-items: center; }
.bt-icon { display: inline-flex; vertical-align: -3px; margin-right: 4px; }

/* pills / status */
.pill { display: inline-flex; align-items: center; padding: 3px 12px; border-radius: 4px; font-size: 12px; color: #fff; font-weight: 500; white-space: nowrap; }

/* misc */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .big { font-size: 40px; margin-bottom: 12px; }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* responsive */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  .sidebar.open { transform: none; }
  .main { margin-left: 64px; }
  .topbar-burger { display: block; }
  .content { padding: 16px; }
}
