/* Crewly PWA — Industrial Terminal Aesthetic */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
    /* Deep industrial dark palette */
    --bg-void: #050505;
    --bg-primary: #0a0a0a;
    --bg-elevated: #111111;
    --bg-surface: #161616;
    --bg-hover: #1c1c1c;
    --bg-active: #222222;

    /* Terminal amber/gold accent */
    --accent: #F5A623;
    --accent-bright: #FFD93D;
    --accent-dim: #C4841D;
    --accent-glow: rgba(245, 166, 35, 0.15);
    --accent-subtle: rgba(245, 166, 35, 0.08);

    /* Semantic colors */
    --positive: #00E676;
    --positive-dim: #00C853;
    --negative: #FF5252;
    --negative-dim: #D50000;
    --warning: #FFAB00;
    --info: #40C4FF;

    /* Text hierarchy */
    --text-primary: #FAFAFA;
    --text-secondary: #999999;
    --text-tertiary: #666666;
    --text-ghost: #444444;

    /* Borders */
    --border-solid: #2a2a2a;
    --border-subtle: #1a1a1a;
    --border-accent: var(--accent);

    /* System */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Typography */
    --font-display: 'Outfit', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    font-family: var(--font-display);
    background: var(--bg-void);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--accent);
    color: var(--bg-void);
}

.hidden { display: none !important; }

.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════
   AUTH SCREEN — Phone + TOTP login
   ═══════════════════════════════════════════════════════════ */
#auth-screen {
    background: var(--bg-void);
    justify-content: center;
    align-items: center;
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    position: relative;
}

#auth-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, var(--accent-glow) 0%, transparent 50%),
        linear-gradient(180deg, transparent 0%, var(--bg-void) 100%);
    pointer-events: none;
}

.auth-container {
    width: 100%;
    max-width: 340px;
    position: relative;
    z-index: 1;
}

.auth-logo {
    text-align: center;
    margin-bottom: 40px;
}

.auth-logo h1 {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.15em;
    margin-bottom: 8px;
}

.auth-logo p {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-tertiary);
}

.auth-form {
    margin-top: 24px;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form .form-input {
    text-align: center;
    font-size: 16px;
}

.auth-form .code-input {
    font-family: var(--font-mono);
    font-size: 24px;
    letter-spacing: 0.3em;
    padding: 16px;
}

/* QR Code container */
.qr-container {
    text-align: center;
    margin: 24px 0;
}

.qr-code {
    display: inline-block;
    background: white;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.qr-code img {
    display: block;
}

.qr-hint {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.secret-code {
    display: block;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    background: var(--bg-surface);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-solid);
    word-break: break-all;
    user-select: all;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: var(--bg-surface);
    border: 2px solid var(--border-solid);
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 20px;
    position: relative;
}

.logo-icon::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent) 0%, transparent 50%);
    opacity: 0.3;
    z-index: -1;
}

/* ═══════════════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════════════ */
#app {
    background: var(--bg-primary);
}

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(52px + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-solid);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.app-header h1 {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.btn-icon {
    position: absolute;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.btn-icon:active {
    background: var(--bg-active);
}

.app-content {
    position: fixed;
    top: calc(52px + var(--safe-top));
    left: 0;
    right: 0;
    bottom: calc(64px + var(--safe-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-primary);
}

/* ═══════════════════════════════════════════════════════════
   TAB BAR — Industrial navigation
   ═══════════════════════════════════════════════════════════ */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-solid);
    display: flex;
    z-index: 100;
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: none;
    background: none;
    color: var(--text-ghost);
    cursor: pointer;
    padding: 8px 0;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: color 0.2s;
    position: relative;
}

.tab-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.2s;
}

.tab-item.active {
    color: var(--accent);
}

.tab-item.active::before {
    width: 32px;
}

.tab-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.5;
}

/* ═══════════════════════════════════════════════════════════
   STATS ROW — Terminal data display
   ═══════════════════════════════════════════════════════════ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border-solid);
    margin: 16px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.stat-item {
    background: var(--bg-surface);
    padding: 16px 12px;
    text-align: center;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.stat-value.positive { color: var(--positive); }
.stat-value.negative { color: var(--negative); }

.stat-label {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ═══════════════════════════════════════════════════════════
   CARDS — Industrial panels
   ═══════════════════════════════════════════════════════════ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-md);
    margin: 12px 16px;
    overflow: hidden;
}

.card-header {
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}

.card-row {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.15s;
}

.card-row:first-child,
.card-header + .card-row {
    border-top: none;
}

.card-row:active {
    background: var(--bg-hover);
}

.card-row-content {
    flex: 1;
    min-width: 0;
}

.card-row-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-row-subtitle {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.card-row-value {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: 12px;
    flex-shrink: 0;
}

.card-row-chevron {
    color: var(--text-ghost);
    margin-left: 8px;
}

/* ═══════════════════════════════════════════════════════════
   LISTS — Data rows
   ═══════════════════════════════════════════════════════════ */
.list-section {
    margin: 16px 0;
}

.list-section-header {
    padding: 8px 16px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-ghost);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.15s;
}

.list-item:first-child {
    border-top: 1px solid var(--border-solid);
}

.list-item:last-child {
    border-bottom: 1px solid var(--border-solid);
}

.list-item:active {
    background: var(--bg-hover);
}

.list-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
    border: 1px solid var(--border-solid);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
    margin-right: 12px;
    flex-shrink: 0;
}

.list-content {
    flex: 1;
    min-width: 0;
}

.list-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-subtitle {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.list-badge {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 8px;
    border: 1px solid;
}

.badge-pending {
    background: rgba(255, 171, 0, 0.1);
    color: var(--warning);
    border-color: rgba(255, 171, 0, 0.3);
}
.badge-active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: rgba(245, 166, 35, 0.3);
}
.badge-completed {
    background: rgba(0, 230, 118, 0.1);
    color: var(--positive);
    border-color: rgba(0, 230, 118, 0.3);
}
.badge-danger {
    background: rgba(255, 82, 82, 0.1);
    color: var(--negative);
    border-color: rgba(255, 82, 82, 0.3);
}

/* ═══════════════════════════════════════════════════════════
   SEARCH
   ═══════════════════════════════════════════════════════════ */
.search-container {
    padding: 12px 16px;
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.search-input::placeholder {
    color: var(--text-ghost);
}

/* ═══════════════════════════════════════════════════════════
   MODAL — Slide-up panel
   ═══════════════════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-height: 90%;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-solid);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-solid);
}

.modal-header h2 {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ═══════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-solid);
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: 15px;
    background: var(--bg-surface);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: var(--font-display);
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-void);
}

.btn-primary:active {
    background: var(--accent-dim);
    transform: scale(0.98);
}

.btn-danger {
    background: var(--negative);
    color: white;
}

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-solid);
    color: var(--text-primary);
}

.btn-secondary:active {
    background: var(--bg-hover);
}

.btn-full {
    width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--border-solid);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 12px;
    z-index: 2000;
    animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* ═══════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 32px;
    text-align: center;
}

.empty-state svg {
    width: 40px;
    height: 40px;
    color: var(--text-ghost);
    margin-bottom: 16px;
    stroke-width: 1;
}

.empty-state h3 {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.empty-state p {
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════
   LOADING
   ═══════════════════════════════════════════════════════════ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-solid);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════
   STATUS & MONEY
   ═══════════════════════════════════════════════════════════ */
.status-draft { color: var(--text-ghost); }
.status-active { color: var(--accent); }
.status-completed { color: var(--positive); }
.status-cancelled { color: var(--negative); }

.money-positive {
    color: var(--positive);
    font-family: var(--font-mono);
}
.money-negative {
    color: var(--negative);
    font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════════════════
   FAB — Floating Action Button
   ═══════════════════════════════════════════════════════════ */
.fab {
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: var(--bg-void);
    border: none;
    box-shadow:
        0 4px 16px rgba(245, 166, 35, 0.3),
        0 0 0 1px rgba(245, 166, 35, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.15s, box-shadow 0.15s;
}

.fab:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(245, 166, 35, 0.2);
}

.fab svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

/* ═══════════════════════════════════════════════════════════
   PULL TO REFRESH
   ═══════════════════════════════════════════════════════════ */
.ptr-indicator {
    text-align: center;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
