/* ==========================================================================
   Material Design 3 (M3) Global Design System - main.css
   ========================================================================== */

:root {
    /* MD3 Color Palette Tokens */
    --md-primary: #005ac1;
    --md-on-primary: #ffffff;
    --md-primary-container: #d8e2ff;
    --md-on-primary-container: #001a41;

    --md-secondary: #575e71;
    --md-secondary-container: #dbe2f9;
    --md-on-secondary-container: #141b2c;

    --md-tertiary: #715b2e;
    --md-tertiary-container: #fde0a6;
    --md-on-tertiary-container: #261a00;

    --md-success: #006c45;
    --md-success-container: #c2eed5;
    --md-on-success-container: #002111;

    --md-warning: #e69900;
    --md-warning-container: #fef3c7;
    --md-on-warning-container: #78350f;

    --md-error: #ba1a1a;
    --md-error-container: #ffdad6;
    --md-on-error-container: #410002;

    --md-surface: #ffffff;
    --md-surface-dim: #f3f4fa;
    --md-surface-container-lowest: #ffffff;
    --md-surface-container-low: #f8f9ff;
    --md-surface-container: #f1f4fb;
    --md-surface-container-high: #e9ecf3;
    --md-surface-container-highest: #e0e3ea;

    --md-on-surface: #1a1c1e;
    --md-on-surface-variant: #44474e;
    --md-outline: #74777f;
    --md-outline-variant: #c4c6cf;
    --md-border-subtle: #e1e3ea;

    /* Backward compatibility variables */
    --bg: #f8f9fe;
    --surface: #ffffff;
    --surface-muted: #f1f4fb;
    --border: #e1e3ea;
    --text: #1a1c1e;
    --muted: #44474e;
    --primary: #005ac1;
    --primary-strong: #001a41;
    --success-bg: #c2eed5;
    --success-text: #006c45;
    --draft-bg: #fef3c7;
    --draft-text: #b45309;
    --danger-bg: #ffdad6;
    --danger-text: #ba1a1a;
    --shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Josefin Sans', sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    padding: 20px 24px;
}

/* -------------------------------------------------------------
   MD3 Top Application Bar
   ------------------------------------------------------------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 22px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.brand-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-link {
    font-size: 1.22rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 0.78rem;
}

/* MD3 Top Navigation */
.top-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    background: var(--surface-muted);
    padding: 3px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.nav-link {
    padding: 7px 16px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    transition: all 0.15s ease;
    line-height: 1.2;
}

.nav-link:hover {
    color: var(--text);
    background: rgba(0, 90, 193, 0.08);
}

.nav-link.active {
    color: var(--md-on-secondary-container);
    background: var(--md-secondary-container);
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
}

.user-role {
    font-size: 0.75rem;
    color: var(--muted);
}

.logout-link {
    padding: 7px 14px;
    border-radius: 8px;
    background: var(--surface-muted);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    border: 1px solid var(--border);
    transition: all 0.15s ease;
}

.logout-link:hover {
    background: #ffdad6;
    color: #ba1a1a;
    border-color: #ffb4ab;
}

/* -------------------------------------------------------------
   MD3 Button System
   ------------------------------------------------------------- */
.primary-btn,
.secondary-btn,
.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 18px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 999px;
    transition: all 0.15s cubic-bezier(0.2, 0, 0, 1);
    cursor: pointer;
    line-height: 1;
    border: none;
}

.primary-btn {
    color: var(--md-on-primary);
    background-color: var(--md-primary);
    box-shadow: 0 1px 3px rgba(0, 90, 193, 0.2);
}

.primary-btn:hover {
    box-shadow: 0 2px 6px rgba(0, 90, 193, 0.3);
    transform: translateY(-1px);
}

.primary-btn:active {
    transform: scale(0.97);
}

.secondary-btn {
    background: var(--md-surface-container);
    color: var(--md-on-surface);
    border: 1px solid var(--md-outline-variant);
}

.secondary-btn:hover {
    background: var(--md-surface-container-high);
    border-color: var(--md-outline);
}

.ghost-btn {
    background: transparent;
    color: var(--md-primary);
    border: 1px solid var(--md-outline);
}

.ghost-btn:hover {
    background: rgba(0, 90, 193, 0.08);
    border-color: var(--md-primary);
}

/* MD3 Card Base */
.panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
    font-weight: 700;
}

.form-message {
    min-height: 18px;
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--muted);
}

.form-message.error {
    color: var(--danger-text);
}

.form-message.success {
    color: var(--success-text);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
}

.status-badge.neutral {
    background: var(--surface-muted);
    color: var(--muted);
    border: 1px solid var(--border);
}

.status-badge.draft {
    background: var(--draft-bg);
    color: var(--draft-text);
    border: 1px solid #fde68a;
}

.status-badge.submitted {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #89dcb0;
}

.lock-notice {
    color: var(--muted);
    font-size: 0.84rem;
}

@media (max-width: 1023px) {
    .app-header {
        flex-wrap: wrap;
    }

    .user-chip {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 767px) {
    .app-shell {
        padding: 14px;
    }

    .app-header {
        padding: 14px;
    }

    .top-nav {
        justify-content: flex-start;
        overflow-x: auto;
    }
}
