*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0A0F09;
  --bg2: #111509;
  --bg3: #181E11;
  --bg4: #1F2716;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.13);
  --text: #F0EDE6;
  --text2: #A8A89A;
  --text3: #5E6052;
  --accent: #8DB87A;
  --accent2: #6A9A58;
  --gold: #C4A94A;
  --gold2: #A68C2A;
  --green: #7AB87A;
  --red: #C47A7A;
  --sidebar-w: 224px;
  --font-display: 'Montserrat', sans-serif;
  --font-body: 'Montserrat', sans-serif;
  --r: 6px;
  --r2: 10px;
}

@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
.screen { display: none; height: 100%; }
.screen.active { display: flex; }

/* AUTH */
#auth-screen { align-items: center; justify-content: center; position: relative; overflow: hidden; }
.auth-bg { position: absolute; inset: 0; background: radial-gradient(ellipse at 25% 60%, rgba(141,184,122,0.07) 0%, transparent 55%), radial-gradient(ellipse at 75% 20%, rgba(196,169,74,0.05) 0%, transparent 50%); }
.auth-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px); background-size: 56px 56px; }
.auth-container { position: relative; z-index: 1; width: 100%; max-width: 380px; padding: 24px; }
.auth-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 36px; justify-content: center; }
.logo-mark { width: 42px; height: 42px; background: var(--accent); color: #0A0F09; font-family: var(--font-display); font-weight: 800; font-size: 13px; border-radius: var(--r); display: flex; align-items: center; justify-content: center; flex-shrink: 0; letter-spacing: 0.05em; }
.logo-mark.sm { width: 28px; height: 28px; font-size: 10px; }
.logo-name { font-family: var(--font-display); font-size: 16px; font-weight: 700; line-height: 1.2; letter-spacing: 0.03em; text-transform: uppercase; }
.logo-sub { font-size: 10px; color: var(--text3); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 2px; }
.auth-card { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r2); padding: 28px; }
.auth-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; }
.auth-hint { font-size: 12px; color: var(--text3); margin-bottom: 24px; }
.btn-google { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 16px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--r); color: var(--text); font-size: 13px; font-family: var(--font-body); font-weight: 500; cursor: pointer; transition: background 0.15s; }
.btn-google:hover { background: var(--bg4); }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text3); font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-error { font-size: 12px; color: var(--red); margin-top: 10px; min-height: 16px; }

/* FIELDS */
.field { display: block; width: 100%; padding: 9px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); font-family: var(--font-body); font-size: 13px; margin-bottom: 10px; transition: border-color 0.15s; outline: none; }
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--text3); }

/* BUTTONS */
.btn-primary { display: inline-flex; align-items: center; justify-content: center; padding: 9px 18px; background: var(--accent); color: #0A0F09; font-family: var(--font-body); font-weight: 700; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; border: none; border-radius: var(--r); cursor: pointer; transition: background 0.15s; }
.btn-primary:hover { background: var(--accent2); }
.btn-primary.full { width: 100%; }

/* LAYOUT */
#main-screen { flex-direction: row; }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; overflow-y: auto; }
.sb-top { padding: 18px 14px 14px; border-bottom: 1px solid var(--border); }
.sb-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sb-logo span { font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.sb-user { font-size: 10px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-nav { flex: 1; padding: 10px 6px; overflow-y: auto; }
.sb-bottom { padding: 8px 6px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

/* NAV */
.nav-dept { margin-bottom: 2px; }
.nav-dept-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; background: none; border: none; color: var(--text2); font-family: var(--font-body); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer; border-radius: var(--r); transition: background 0.12s, color 0.12s; text-align: left; }
.nav-dept-btn:hover, .nav-dept-btn.active { background: var(--bg3); color: var(--text); }
.nav-dept-btn.active { color: var(--accent); }
.chevron { margin-left: auto; opacity: 0.4; transition: transform 0.2s; }
.nav-dept-btn.open .chevron { transform: rotate(90deg); }
.nav-sub { display: none; padding-left: 10px; margin-top: 1px; }
.nav-sub.open { display: block; }
.nav-sub-item { display: block; width: 100%; padding: 5px 10px; background: none; border: none; color: var(--text3); font-family: var(--font-body); font-size: 11px; font-weight: 500; cursor: pointer; border-radius: 5px; text-align: left; transition: background 0.12s, color 0.12s; margin-bottom: 1px; }
.nav-sub-item:hover { background: var(--bg3); color: var(--text2); }
.nav-sub-item.active { color: var(--accent); background: rgba(141,184,122,0.08); }
.nav-standalone { display: block; width: 100%; padding: 7px 10px; background: none; border: none; color: var(--text2); font-family: var(--font-body); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer; border-radius: var(--r); text-align: left; transition: background 0.12s, color 0.12s; margin-bottom: 2px; }
.nav-standalone:hover { background: var(--bg3); color: var(--text); }
.nav-standalone.active { background: var(--bg3); color: var(--accent); }
.nav-sep { height: 1px; background: var(--border); margin: 8px 4px; }
.sb-action { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; background: none; border: none; color: var(--text3); font-family: var(--font-body); font-size: 11px; font-weight: 500; cursor: pointer; border-radius: var(--r); transition: background 0.12s, color 0.12s; text-align: left; }
.sb-action:hover { background: var(--bg3); color: var(--text2); }
.sb-action.danger:hover { color: var(--red); }

/* CONTENT */
.content { flex: 1; overflow-y: auto; padding: 40px 48px; }
@media (max-width: 900px) { .content { padding: 24px 20px; } }

/* PAGE */
.page-eyebrow { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.page-title { font-family: var(--font-display); font-size: 28px; font-weight: 800; line-height: 1.15; margin-bottom: 10px; letter-spacing: -0.01em; }
.page-desc { font-size: 13px; color: var(--text2); max-width: 560px; line-height: 1.75; margin-bottom: 36px; }

/* HOME */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.dept-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r2); padding: 22px; cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.dept-card:hover { border-color: var(--border2); background: var(--bg3); }
.dept-card.standalone { border-left: 3px solid var(--accent); }
.dept-icon { font-size: 16px; margin-bottom: 12px; opacity: 0.7; }
.dept-name { font-family: var(--font-display); font-size: 14px; font-weight: 700; margin-bottom: 5px; letter-spacing: 0.01em; text-transform: uppercase; }
.dept-meta { font-size: 12px; color: var(--text3); line-height: 1.5; }
.dept-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }

/* BLOCKS */
.module-sections { display: flex; flex-direction: column; gap: 20px; }
.block { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r2); overflow: hidden; }
.block-header { padding: 14px 20px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.block-title { font-size: 10px; font-weight: 700; color: var(--text3); letter-spacing: 0.1em; text-transform: uppercase; }
.block-body { padding: 20px; }

/* EDITABLE */
[contenteditable] { outline: none; border-radius: 3px; padding: 1px 3px; margin: -1px -3px; transition: background 0.15s; }
[contenteditable]:hover { background: rgba(255,255,255,0.04); }
[contenteditable]:focus { background: rgba(141,184,122,0.09); box-shadow: 0 0 0 1.5px rgba(141,184,122,0.25); }
.edit-tip { font-size: 10px; color: var(--text3); margin-top: 6px; opacity: 0; transition: opacity 0.2s; letter-spacing: 0.02em; }
.block-body:hover .edit-tip { opacity: 1; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.kpi-card { background: var(--bg3); border-radius: var(--r); padding: 14px; border-left: 2px solid var(--accent); }
.kpi-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; font-weight: 600; }
.kpi-value { font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.kpi-sub { font-size: 11px; color: var(--text3); margin-top: 3px; }
.up { color: var(--green); } .down { color: var(--red); }

/* TASKS */
.task-list { display: flex; flex-direction: column; gap: 5px; }
.task-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; background: var(--bg3); border-radius: var(--r); border: 1px solid var(--border); }
.task-check { width: 15px; height: 15px; border-radius: 3px; border: 1.5px solid var(--border2); flex-shrink: 0; margin-top: 2px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.task-check.done { background: var(--green); border-color: var(--green); }
.task-check.done::after { content: ''; width: 7px; height: 4px; border-left: 1.5px solid #0A0F09; border-bottom: 1.5px solid #0A0F09; transform: rotate(-45deg) translateY(-1px); display: block; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13px; line-height: 1.5; }
.task-title.done { text-decoration: line-through; color: var(--text3); }
.task-meta { font-size: 11px; color: var(--text3); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.owner { color: var(--accent); font-weight: 600; }

/* GATES */
.gate-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg3); border-radius: var(--r); border: 1px solid var(--border); margin-bottom: 8px; }
.gate-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; letter-spacing: 0.04em; text-transform: uppercase; }
.gate-badge.locked { background: rgba(196,122,122,0.12); color: var(--red); border: 1px solid rgba(196,122,122,0.18); }
.gate-badge.open { background: rgba(122,184,122,0.12); color: var(--green); border: 1px solid rgba(122,184,122,0.18); }
.gate-label { font-size: 13px; color: var(--text2); flex: 1; }
.gate-amount { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--gold); }

/* DRAWER */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.overlay.active { opacity: 1; pointer-events: all; }
.drawer { position: fixed; top: 0; right: 0; width: 420px; max-width: 95vw; height: 100vh; background: var(--bg2); border-left: 1px solid var(--border2); z-index: 101; transform: translateX(100%); transition: transform 0.25s cubic-bezier(0.4,0,0.2,1); display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.drawer-head h2 { font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }

/* MODAL */
.modal-wrap { position: fixed; inset: 0; z-index: 101; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.modal-wrap.active { opacity: 1; pointer-events: all; }
.modal { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r2); width: 540px; max-width: 95vw; max-height: 85vh; overflow-y: auto; }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.modal-body { padding: 20px; }
.icon-btn { background: none; border: none; color: var(--text3); cursor: pointer; padding: 4px; border-radius: 5px; display: flex; align-items: center; justify-content: center; transition: color 0.15s, background 0.15s; }
.icon-btn:hover { color: var(--text); background: var(--bg3); }

/* INVITE */
.invite-row { display: flex; gap: 8px; flex-wrap: wrap; }
.section-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text3); font-weight: 700; margin-bottom: 10px; }
.small-msg { font-size: 12px; margin-top: 6px; color: var(--green); min-height: 18px; }

/* USER ROWS */
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-av { width: 30px; height: 30px; border-radius: 50%; background: var(--bg4); border: 1px solid var(--border2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-email { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { font-size: 10px; padding: 2px 8px; border-radius: 20px; background: var(--bg4); color: var(--text3); border: 1px solid var(--border); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.role-badge.admin { background: rgba(141,184,122,0.1); color: var(--accent); border-color: rgba(141,184,122,0.2); }
.btn-rm { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 11px; padding: 3px 7px; border-radius: 4px; transition: color 0.15s; }
.btn-rm:hover { color: var(--red); }

/* CHANGELOG */
.cl-entry { padding: 12px 0; border-bottom: 1px solid var(--border); }
.cl-entry:last-child { border-bottom: none; }
.cl-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.cl-user { font-size: 12px; font-weight: 700; color: var(--accent); }
.cl-time { font-size: 11px; color: var(--text3); }
.cl-page { font-size: 10px; padding: 2px 7px; border-radius: 20px; background: var(--bg4); color: var(--text3); border: 1px solid var(--border); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.cl-field { font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.cl-old { font-size: 11px; color: var(--red); background: rgba(196,122,122,0.07); padding: 3px 8px; border-radius: 4px; border-left: 2px solid rgba(196,122,122,0.4); margin-bottom: 3px; word-break: break-word; }
.cl-new { font-size: 11px; color: var(--green); background: rgba(122,184,122,0.07); padding: 3px 8px; border-radius: 4px; border-left: 2px solid rgba(122,184,122,0.4); word-break: break-word; }

/* TOAST */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--bg4); border: 1px solid var(--border2); border-radius: var(--r); padding: 10px 16px; font-size: 12px; font-weight: 500; z-index: 200; transform: translateY(8px); opacity: 0; transition: all 0.2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.hidden { display: none; }

/* MISC */
.hidden { display: none !important; }
.muted { color: var(--text3); font-size: 13px; }
.center { text-align: center; padding: 24px 0; }
.tag { display: inline-flex; font-size: 10px; padding: 2px 8px; border-radius: 20px; background: var(--bg4); color: var(--text3); border: 1px solid var(--border); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.tag.green { background: rgba(141,184,122,0.1); color: var(--accent); border-color: rgba(141,184,122,0.2); }
.tag.gold { background: rgba(196,169,74,0.1); color: var(--gold); border-color: rgba(196,169,74,0.2); }
.tag.red { background: rgba(196,122,122,0.1); color: var(--red); border-color: rgba(196,122,122,0.2); }
.progress-bar { height: 3px; background: var(--bg4); border-radius: 2px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); font-weight: 700; padding: 0 10px 8px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text2); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* WHO BADGES */
.who { display: inline-flex; font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 3px; color: #0A0F09; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.wf { background: #4A7FB5; color: #fff; }
.ws { background: #7A7AB5; color: #fff; }
.wz { background: #9A5AB5; color: #fff; }
.wall { background: var(--accent); color: #0A0F09; }
.wm { background: var(--bg4); color: var(--text2); border: 1px solid var(--border2); }

/* PRIORITY ROWS */
.pri-row { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.pri-row:last-child { border-bottom: none; }
.pri-num { font-size: 26px; font-weight: 800; color: var(--bg4); line-height: 1; flex-shrink: 0; width: 36px; }
.pri-body h4 { font-size: 13px; font-weight: 700; margin-bottom: 5px; }
.pri-body p { font-size: 13px; color: var(--text2); line-height: 1.6; }
