/* ===========================================================
   Crew HQ — design tokens
   Palette: ink (charcoal), paper (warm off-white), rust (primary
   action / punch-clock), moss (success/active), amber (pending),
   slate (secondary). Inspired by a physical time-clock & workboard.
=========================================================== */
:root {
    --ink: #1C2321;
    --ink-soft: #2A332F;
    --paper: #F6F3EC;
    --paper-raised: #FFFFFF;
    --rust: #C1502E;
    --rust-dark: #A23F23;
    --moss: #4B6B53;
    --moss-soft: #E4ECE5;
    --amber: #E3A857;
    --amber-soft: #FBF0DD;
    --slate: #55697A;
    --slate-soft: #E7EBEE;
    --danger: #A23B2E;
    --danger-soft: #F6E3DF;
    --border: #E2DDD0;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); margin: 0 0 12px; }
.no-margin { margin: 0; }
.muted { color: var(--slate); font-size: 0.85rem; }

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

.sidebar {
    background: var(--ink);
    color: var(--paper);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 32px; }
.brand-lg { margin-bottom: 8px; justify-content: center; }
.brand-mark {
    font-family: var(--font-display);
    font-weight: 700;
    background: var(--rust);
    color: white;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    font-size: 0.9rem;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }

.nav-links { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    color: #C9CFC8; font-weight: 500; font-size: 0.92rem;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--ink-soft); color: var(--paper); }
.nav-link.is-active { background: var(--rust); color: white; }
.nav-icon { width: 18px; text-align: center; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 16px; }
.me { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.me-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--amber); color: var(--ink);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; flex-shrink: 0;
}
.me-avatar-lg { width: 56px; height: 56px; font-size: 1.4rem; }
.me-name { font-weight: 600; font-size: 0.9rem; }
.me-role { font-size: 0.78rem; color: #9AA39C; text-transform: capitalize; }
.link-btn {
    background: none; border: none; color: #C9CFC8; font-size: 0.85rem;
    cursor: pointer; padding: 0; text-decoration: underline;
}
.link-btn-danger { color: var(--danger); }

.main-content { padding: 28px 36px 90px; max-width: 1100px; }
.topbar { margin-bottom: 20px; }
.topbar h1 { font-size: 1.6rem; }

.page-body { display: flex; flex-direction: column; gap: 20px; }

.bottom-tabs { display: none; }

/* ---------- Flash ---------- */
.flash {
    background: var(--moss-soft); color: var(--moss);
    padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem;
}
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-error ul { margin: 0; padding-left: 18px; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card {
    background: var(--paper-raised); border: 1px solid var(--border);
    border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 4px;
}
.stat-value { font-family: var(--font-mono); font-size: 1.8rem; font-weight: 600; }
.stat-label { font-size: 0.82rem; color: var(--slate); }
.stat-accent .stat-value { color: var(--rust); }
.stat-danger .stat-value { color: var(--danger); }

/* ---------- Panels ---------- */
.panel-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.panel {
    background: var(--paper-raised); border: 1px solid var(--border);
    border-radius: 12px; padding: 20px;
}
.panel-hero { grid-column: 1 / -1; text-align: center; padding: 32px 20px; }
.hero-status { font-size: 1rem; margin-bottom: 16px; }

.list-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.list-row:last-child { border-bottom: none; }
.empty { color: var(--slate); font-size: 0.88rem; font-style: italic; }
.empty-small { padding: 10px 0; text-align: center; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--moss); box-shadow: 0 0 0 3px var(--moss-soft); }
.dot-muted { background: var(--slate); }

/* ---------- Buttons & forms ---------- */
.btn {
    font-family: var(--font-body); font-weight: 600; font-size: 0.9rem;
    padding: 10px 18px; border-radius: 8px; border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    transition: transform 0.1s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--rust); color: white; }
.btn-primary:hover { background: var(--rust-dark); }
.btn-ghost { background: var(--slate-soft); color: var(--ink); }
.btn-block { width: 100%; }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input, .inline-form select {
    padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
    font-family: var(--font-body); font-size: 0.88rem; background: var(--paper);
}

.stacked-form { display: flex; flex-direction: column; gap: 14px; max-width: 460px; }
.stacked-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; }
.stacked-form input, .stacked-form select, .stacked-form textarea {
    font-family: var(--font-body); font-weight: 400; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--paper); font-size: 0.92rem;
}
.checkbox-row { flex-direction: row !important; align-items: center; gap: 8px !important; }

/* ---------- Auth page ---------- */
.auth-body {
    background: var(--ink); min-height: 100vh; display: flex;
    align-items: center; justify-content: center; font-family: var(--font-body);
    margin: 0;
}
.auth-card {
    background: var(--paper-raised); border-radius: 16px; padding: 36px;
    width: 100%; max-width: 380px; text-align: center;
}
.auth-tag { color: var(--slate); font-size: 0.88rem; margin-bottom: 20px; }
.auth-hint { margin-top: 18px; font-size: 0.8rem; color: var(--slate); }
.auth-card .stacked-form { text-align: left; max-width: none; }

/* ---------- Week schedule ---------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; }
.week-label { font-family: var(--font-mono); font-weight: 600; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.day-col { background: var(--paper-raised); border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-height: 140px; }
.day-head { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--slate); margin-bottom: 8px; font-weight: 600; }
.day-head.is-today { color: var(--rust); }
.day-num { font-family: var(--font-mono); }
.shift-card {
    background: var(--amber-soft); border-left: 3px solid var(--amber);
    border-radius: 6px; padding: 8px; margin-bottom: 6px; font-size: 0.78rem;
    display: flex; flex-direction: column; gap: 2px;
}
.shift-card strong { font-size: 0.82rem; }

/* ---------- Punch clock ---------- */
.punch-card {
    background: var(--ink); color: var(--paper); border-radius: 16px;
    padding: 40px 20px; text-align: center;
}
.punch-clock-display {
    font-family: var(--font-mono); font-size: 3.2rem; font-weight: 600; letter-spacing: 1px;
}
.punch-date { color: #9AA39C; margin-bottom: 20px; font-size: 0.9rem; }
.punch-status { margin-bottom: 16px; font-size: 0.95rem; }
.punch-form { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.punch-form textarea {
    width: 100%; max-width: 360px; padding: 10px; border-radius: 8px; border: none;
    font-family: var(--font-body); font-size: 0.88rem; resize: vertical; min-height: 50px;
}
.btn-stamp {
    font-family: var(--font-display); font-size: 1.1rem; font-weight: 700;
    padding: 18px 44px; border-radius: 50px; letter-spacing: 0.5px;
    text-transform: uppercase;
}
.btn-stamp-in { background: var(--moss); color: white; }
.btn-stamp-out { background: var(--rust); color: white; }
.location-hint { margin-top: 14px; font-size: 0.76rem; color: #9AA39C; }

/* ---------- Tasks ---------- */
.task-row {
    display: flex; align-items: center; gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.task-row.is-complete .task-title { text-decoration: line-through; color: var(--slate); }
.checkbox-btn { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--moss); }
.task-body { display: flex; flex-direction: column; flex: 1; gap: 2px; }
.task-title { font-weight: 600; font-size: 0.92rem; }
.priority-tag {
    font-size: 0.7rem; text-transform: uppercase; font-weight: 700;
    padding: 3px 8px; border-radius: 20px;
}
.priority-low { background: var(--slate-soft); color: var(--slate); }
.priority-normal { background: var(--amber-soft); color: #8A6428; }
.priority-high { background: var(--danger-soft); color: var(--danger); }

/* ---------- Time Off ---------- */
.status-tag {
    font-size: 0.7rem; text-transform: uppercase; font-weight: 700;
    padding: 3px 8px; border-radius: 20px;
}
.status-pending { background: var(--amber-soft); color: #8A6428; }
.status-approved { background: var(--moss-soft); color: var(--moss); }
.status-denied { background: var(--danger-soft); color: var(--danger); }

/* ---------- Chat ---------- */
.chat-panel { display: flex; flex-direction: column; height: 70vh; }
.chat-feed { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.chat-message { display: flex; gap: 10px; }
.chat-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--slate-soft);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
    font-family: var(--font-display); font-size: 0.8rem; flex-shrink: 0;
}
.chat-bubble { background: var(--paper); border-radius: 10px; padding: 10px 14px; max-width: 480px; }
.chat-message.is-announcement .chat-bubble { background: var(--amber-soft); border: 1px solid var(--amber); }
.chat-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 0.82rem; }
.tag-announcement {
    background: var(--amber); color: var(--ink); font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; padding: 2px 6px; border-radius: 10px;
}
.chat-bubble p { margin: 0; font-size: 0.9rem; }
.chat-composer { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.chat-composer textarea {
    padding: 10px; border-radius: 8px; border: 1px solid var(--border);
    font-family: var(--font-body); resize: vertical; min-height: 44px;
}
.chat-composer-actions { display: flex; justify-content: space-between; align-items: center; }

/* ---------- Directory ---------- */
.directory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.directory-card {
    display: flex; align-items: center; gap: 10px; padding: 12px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--paper);
}
.directory-card:hover { border-color: var(--rust); }
.directory-card.is-archived { opacity: 0.5; }
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }

/* ---------- Kiosk ---------- */
.kiosk-card { max-width: 420px; }
.kiosk-card .punch-card { padding: 20px; margin-bottom: 20px; }
.kiosk-card .punch-clock-display { font-size: 2.2rem; }
.kiosk-card .punch-date { margin-bottom: 0; }
.kiosk-prompt { color: var(--slate); font-size: 0.9rem; margin-bottom: 16px; }
.kiosk-hint { margin-top: 16px; font-size: 0.85rem; }
.keypad-display {
    font-family: var(--font-mono); font-size: 1.6rem; letter-spacing: 2px;
    text-align: center; padding: 10px; margin-bottom: 14px;
    background: var(--paper); border-radius: 8px; min-height: 1.6rem;
}
.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.keypad-btn {
    font-family: var(--font-display); font-size: 1.4rem; font-weight: 600;
    padding: 20px 0; border-radius: 10px; border: 1px solid var(--border);
    background: var(--paper-raised); cursor: pointer;
}
.keypad-btn:active { background: var(--slate-soft); }
.keypad-btn-muted { font-size: 0.9rem; color: var(--slate); }
.keypad-confirm:disabled { opacity: 0.4; cursor: not-allowed; }
.kiosk-result-icon {
    width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: white;
}
.kiosk-result-icon.is-in { background: var(--moss); }
.kiosk-result-icon.is-out { background: var(--rust); }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main-content { padding: 20px 16px 90px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-grid { grid-template-columns: 1fr; }
    .week-grid { grid-template-columns: 1fr; }

    .bottom-tabs {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0;
        background: var(--ink); padding: 8px 4px; justify-content: space-around;
        z-index: 10;
    }
    .bottom-tabs a {
        display: flex; flex-direction: column; align-items: center; gap: 2px;
        color: #9AA39C; font-size: 1.1rem;
    }
    .bottom-tabs a span { font-size: 0.65rem; }
    .bottom-tabs a.is-active { color: var(--rust); }
}
