/* ==========================================================
   Niro Dev — Project Hub
   Brand tokens mirror nirodev.online
   ========================================================== */
:root {
  --bg:        #090E14;
  --panel:     #101820;
  --panel-2:   #141E28;
  --border:    #18252F;
  --border-2:  #223341;
  --accent:    #38BDF8;
  --accent-ink:#04121C;
  --accent-dim: rgba(56,189,248,.12);
  --text:      #E0F2FE;
  --muted:     #A0AABF;
  --faint:     rgba(160,170,191,.45);
  --shadow:    0 20px 50px rgba(0,0,0,.45);

  /* status / priority colors */
  --c-planning: #A78BFA;
  --c-progress: #38BDF8;
  --c-review:   #FBBF24;
  --c-hold:     #94A3B8;
  --c-done:     #34D399;
  --c-danger:   #F87171;

  --f-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg:        #F4F7FA;
  --panel:     #FFFFFF;
  --panel-2:   #F7FAFC;
  --border:    #E3E9EF;
  --border-2:  #D3DCE5;
  --accent:    #0E9BD8;
  --accent-ink:#FFFFFF;
  --accent-dim: rgba(14,155,216,.10);
  --text:      #18211D;
  --muted:     #5D6B7A;
  --faint:     rgba(93,107,122,.55);
  --shadow:    0 20px 50px rgba(15,30,45,.14);

  --c-planning: #7C3AED;
  --c-progress: #0E9BD8;
  --c-review:   #D97706;
  --c-hold:     #64748B;
  --c-done:     #059669;
  --c-danger:   #DC2626;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 24px 16px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.brand { display: block; padding: 0 8px; }
.logo { height: 34px; width: auto; display: block; }
.logo-on-light { display: none; }
[data-theme="light"] .logo-on-dark { display: none; }
[data-theme="light"] .logo-on-light { display: block; }
.brand-sub {
  display: block; margin: 8px 8px 28px;
  font: 500 11px var(--f-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted);
}

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--muted); cursor: pointer; text-align: left;
  font-weight: 500; transition: background .2s, color .2s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.ghost-btn {
  padding: 8px 12px; border: 0; border-radius: 8px; background: none;
  color: var(--muted); font-size: 13px; text-align: left; cursor: pointer;
}
.ghost-btn:hover { background: var(--panel-2); color: var(--text); }

.main { min-width: 0; padding: 28px 36px 60px; }

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.topbar p { margin: 2px 0 0; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.icon-btn.menu-btn { display: none; }

.search {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 40px; width: 280px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.filters select, .field input, .field select, .field textarea, .add-row input {
  height: 38px; padding: 0 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  outline: 0; color: var(--text);
}
.filters select { cursor: pointer; }
.filters select:focus, .field :is(input,select,textarea):focus, .add-row input:focus { border-color: var(--accent); }
.chip-btn {
  height: 38px; padding: 0 14px; border-radius: 10px; cursor: pointer;
  border: 1px dashed var(--border-2); background: none; color: var(--muted);
}
.chip-btn:hover { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--panel); color: var(--text);
  font-weight: 600; transition: transform .15s, background .2s, border-color .2s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { height: 38px; padding: 0 14px; }
.btn.danger-ghost { background: none; border-color: transparent; color: var(--c-danger); }
.btn.danger-ghost:hover { border-color: var(--c-danger); }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ---------- Badges ---------- */
.badge {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.s-planning { --c: var(--c-planning); }
.s-progress { --c: var(--c-progress); }
.s-review   { --c: var(--c-review); }
.s-hold     { --c: var(--c-hold); }
.s-done     { --c: var(--c-done); }
.p-low      { --c: var(--c-hold); }
.p-medium   { --c: var(--c-progress); }
.p-high     { --c: var(--c-review); }
.p-urgent   { --c: var(--c-danger); }
.tag {
  font: 500 11px var(--f-mono); letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Progress bar ---------- */
.bar { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transition: width .5s var(--ease); }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  padding: 20px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
}
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 32px; font-weight: 700; letter-spacing: -.03em; margin-top: 4px; }
.stat .hint { font-size: 12px; color: var(--faint); }
.stat.alert .value { color: var(--c-danger); }

.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
}
.panel h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.panel + .panel { margin-top: 16px; }

.row-list { list-style: none; margin: 0; padding: 0; }
.row-list li {
  display: grid; grid-template-columns: 1fr 160px 104px; align-items: center; gap: 16px;
  padding: 12px 10px; margin: 0 -10px; border-radius: 10px; cursor: pointer;
}
.row-list li:hover { background: var(--panel-2); }
.row-list .name { font-weight: 600; }
.row-list .sub { font-size: 12px; color: var(--muted); }
.row-list li > .badge { justify-self: end; }
.row-list .pct { font: 500 12px var(--f-mono); color: var(--muted); text-align: right; margin-top: 4px; }

.status-breakdown { display: flex; flex-direction: column; gap: 12px; }
.sb-row { display: grid; grid-template-columns: 90px 1fr 28px; gap: 12px; align-items: center; font-size: 13px; }
.sb-row b { text-align: right; font-family: var(--f-mono); font-weight: 500; }

.due-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); cursor: pointer; }
.due-item:first-of-type { border-top: 0; }
.due-item:hover .name { color: var(--accent); }
.due-date { font: 500 12px var(--f-mono); white-space: nowrap; }
.due-date.over { color: var(--c-danger); }
.due-date.soon { color: var(--c-review); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------- Board ---------- */
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(216px, 1fr);
  gap: 16px; overflow-x: auto; padding-bottom: 12px; align-items: start;
}
.column {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; min-height: 200px; transition: border-color .2s, background .2s;
}
.column.drop { border-color: var(--accent); background: var(--accent-dim); }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 12px; }
.column-head .count { font: 500 12px var(--f-mono); color: var(--muted); }
.cards { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }

.card {
  padding: 14px; border-radius: 10px; cursor: grab;
  background: var(--panel-2); border: 1px solid var(--border);
  transition: border-color .2s, transform .2s var(--ease), box-shadow .2s;
}
.card:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.card.dragging { opacity: .4; }
.card-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.card h4 { margin: 0 0 2px; font-size: 14px; font-weight: 600; line-height: 1.35; }
.card .client { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.avatar {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent); font-size: 10px; font-weight: 700;
}

/* ---------- Table ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th {
  font: 500 11px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  cursor: pointer; user-select: none; white-space: nowrap;
}
th:hover { color: var(--text); }
th.sorted { color: var(--accent); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
td .name { font-weight: 600; }
td .sub { font-size: 12px; color: var(--muted); }
.progress-cell { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.progress-cell .bar { flex: 1; }
.progress-cell span { font: 500 12px var(--f-mono); color: var(--muted); width: 36px; text-align: right; }

/* ---------- Drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(560px, 100%);
  background: var(--panel); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(100%); visibility: hidden;
  transition: transform .4s var(--ease), visibility 0s .4s;
}
.drawer.open { transform: none; visibility: visible; transition: transform .4s var(--ease); }
.drawer form { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.eyebrow { font: 500 11px var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 32px; display: flex; flex-direction: column; gap: 18px; }
.drawer-foot { display: flex; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); }
.spacer { flex: 1; }

.title-input {
  border: 0; outline: 0; background: none; padding: 0;
  font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: var(--text);
}
.title-input::placeholder { color: var(--faint); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; }
.field > span b { color: var(--accent); font-family: var(--f-mono); font-weight: 500; }
.field textarea { height: auto; padding: 10px 12px; resize: vertical; }
.field input[type="date"] { color-scheme: dark; }
[data-theme="light"] .field input[type="date"] { color-scheme: light; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="range"]:disabled { opacity: .6; }

.block { border-top: 1px solid var(--border); padding-top: 18px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.block h3 { margin: 0; font-size: 14px; font-weight: 600; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; min-width: 0; }

.tasks, .notes { list-style: none; margin: 0 0 10px; padding: 0; }
.tasks li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 0 -10px; border-radius: 8px;
}
.tasks li:hover { background: var(--panel-2); }
.tasks input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.tasks .t-text { flex: 1; }
.tasks li.done .t-text { text-decoration: line-through; color: var(--faint); }
.tasks .remove { opacity: 0; width: 28px; height: 28px; }
.tasks li:hover .remove { opacity: 1; }

.notes { margin: 12px 0 0; }
.notes li { padding: 10px 0 10px 14px; border-left: 2px solid var(--border-2); margin-left: 4px; }
.notes time { display: block; font: 500 11px var(--f-mono); color: var(--faint); margin-bottom: 2px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 13px;
  transition: opacity .25s, transform .35s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; z-index: 45; width: 260px;
    transform: translateX(-100%); transition: transform .35s var(--ease);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .icon-btn.menu-btn { display: grid; }
  .main { padding: 18px 16px 48px; }
  .topbar-actions { margin-left: 0; width: 100%; }
  .search { flex: 1; width: auto; }
  .row-list li { grid-template-columns: 1fr auto; }
  .row-list li > div:nth-child(2) { display: none; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 26px; }
  .grid-2 { grid-template-columns: 1fr; }
  .filters select { flex: 1; }
  .drawer-body, .drawer-head, .drawer-foot { padding-left: 16px; padding-right: 16px; }
}

/* ==========================================================
   Accounts: login page, user menu, dialogs, users admin
   ========================================================== */
body.booting .app { visibility: hidden; }
.small { font-size: 12px; }
.form-error { margin: 0; min-height: 0; color: var(--c-danger); font-size: 13px; font-weight: 500; }
.form-error:empty { display: none; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: default; }

/* Login */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.auth-card {
  width: min(400px, 100%); padding: 32px 28px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.auth-card .brand-sub { margin: 8px 0 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.auth-form p { margin: 0; }
.auth-form .field input { height: 42px; }

/* Signed-in user */
.me {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0 4px; padding: 12px 12px 4px; border-top: 1px solid var(--border);
}
.me .avatar { width: 32px; height: 32px; font-size: 12px; }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.me-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span { font-size: 12px; color: var(--muted); text-transform: capitalize; }

/* Dialogs */
.modal {
  width: min(440px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
.modal form { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal-foot { display: flex; gap: 8px; margin-top: 6px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

/* Users admin */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 2px 0 0; font-size: 13px; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell .avatar { width: 32px; height: 32px; font-size: 12px; }
.r-admin { --c: var(--accent); }
.r-member { --c: var(--c-hold); }
.u-active { --c: var(--c-done); }
.u-disabled { --c: var(--c-danger); }
tr.is-disabled td { opacity: .6; }
.you { font: 500 10px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-left: 6px; }
.notes .author { color: var(--muted); }
.loading-line { padding: 40px; text-align: center; color: var(--muted); }
