/* =============================================
   DEWAN AI — ANTHROPIC-INSPIRED DESIGN SYSTEM
   Palette: Ivory · Slate · Clay · White
   Fonts: Lora (serif headings) + Inter (UI)
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lora:wght@400;500;600;700&display=swap');

/* =============================================
   MOBILE TAP HIGHLIGHT — must be global
   ============================================= */
*,
*::before,
*::after {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    -webkit-touch-callout: none;
}

a, button, input, select, textarea, label,
[role="button"], [onclick] {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    outline: none;
}

/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
    /* — Anthropic Swatches — */
    --ivory-light:     #faf9f5;
    --ivory-medium:    #f0eee6;
    --ivory-dark:      #e8e6dc;
    --slate-dark:      #141413;
    --slate-medium:    #3d3d3a;
    --slate-light:     #5e5d59;
    --cloud-medium:    #b0aea5;
    --cloud-light:     #d1cfc5;
    --clay:            #d97757;
    --clay-light:      #f0d5c8;
    --clay-dark:       #b85e3e;
    --white:           #ffffff;
    --slate-faded-10:  rgba(20, 20, 19, 0.10);
    --slate-faded-20:  rgba(20, 20, 19, 0.20);

    /* — Semantic Color Roles — */
    --primary:         var(--slate-dark);
    --primary-hover:   var(--slate-medium);

    --accent:          var(--clay);
    --accent-light:    var(--clay-light);
    --accent-dark:     var(--clay-dark);

    /* Backgrounds */
    --bg-primary:      var(--ivory-light);
    --bg-secondary:    var(--ivory-medium);
    --bg-card:         var(--white);
    --bg-card-hover:   var(--ivory-light);
    --bg-hover:        var(--ivory-medium);
    --bg-input:        var(--ivory-medium);
    --bg-sidebar:      var(--ivory-medium);
    --bg-header:       rgba(250, 249, 245, 0.92);

    /* Text */
    --text-primary:    var(--slate-dark);
    --text-secondary:  var(--slate-light);
    --text-muted:      var(--cloud-medium);
    --text-inverse:    var(--ivory-light);

    /* Borders */
    --border:          var(--slate-faded-10);
    --border-light:    rgba(20, 20, 19, 0.06);
    --border-dark:     var(--slate-faded-20);

    /* Status */
    --success:         #2d6a4f;
    --success-light:   #d8f3dc;
    --success-dark:    #1b4332;
    --warning:         #b5830a;
    --warning-light:   #fef3c7;
    --warning-dark:    #7c5d08;
    --danger:          #c0392b;
    --danger-light:    #fde8e8;
    --danger-dark:     #96281b;
    --info:            #1a5276;
    --info-light:      #d6eaf8;
    --info-dark:       #154360;

    /* Shadows — minimal, editorial */
    --shadow-sm:  0 1px 2px rgba(20, 20, 19, 0.05);
    --shadow-md:  0 2px 8px rgba(20, 20, 19, 0.07);
    --shadow-lg:  0 4px 20px rgba(20, 20, 19, 0.09);
    --shadow-xl:  0 8px 30px rgba(20, 20, 19, 0.10);

    /* Radius — restrained like Anthropic */
    --radius-sm:   6px;
    --radius-md:   8px;
    --radius-lg:   10px;
    --radius-xl:   14px;
    --radius-full: 9999px;

    /* Transitions */
    --transition:      all 0.18s ease;
    --transition-slow: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --sidebar-width: 252px;
    --header-height: 58px;

    /* Fonts */
    --font-serif: 'Lora', Georgia, 'Times New Roman', serif;
    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--slate-medium);
}

img {
    max-width: 100%;
    height: auto;
}

/* Headings — serif for editorial weight */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; letter-spacing: -0.015em; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

/* =============================================
   AUTH PAGES  — native-app style
   ============================================= */
.auth-body {
    background: var(--bg-primary);
}

.auth-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

/* Hero zone */
.auth-hero {
    flex: 0 0 45%;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 3rem 3rem 4rem;
}

.auth-hero-sub {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    letter-spacing: 0.01em;
}

.auth-hero-title {
    font-family: var(--font-serif);
    font-size: clamp(2.4rem, 3.5vw, 3.5rem);
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

/* Form panel */
.auth-panel {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
    background: var(--white);
}

.auth-inner {
    width: 100%;
    max-width: 360px;
}

/* Google button */
.auth-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1.5px solid var(--border-dark);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--text-dark);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s, border-color 0.12s;
    cursor: pointer;
}

.auth-google-btn:hover {
    background: var(--bg-hover);
    border-color: var(--slate-dark);
}

.auth-google-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-family: var(--font-sans);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-dark);
}

/* Form fields */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.auth-field {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.auth-field:first-child {
    border-top: 1px solid var(--border);
}

.auth-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 3px;
    font-family: var(--font-sans);
}

.auth-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--text-dark);
    padding: 0;
}

.auth-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Submit button */
.auth-submit-btn {
    margin-top: 1.5rem;
    width: 100%;
    padding: 0.85rem;
    background: var(--slate-dark);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.12s;
}

.auth-submit-btn:hover {
    opacity: 0.88;
}

/* Switch link */
.auth-switch-link {
    text-align: center;
    margin-top: 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-switch-link a {
    color: var(--text-dark);
    font-weight: 500;
    text-decoration: none;
}

/* Alert */
.auth-alert {
    background: var(--danger-light);
    color: var(--danger-dark);
    border: 1px solid #f0b8b8;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

.auth-alert-success {
    background: var(--success-light);
    color: var(--success-dark);
    border-color: #a8d5b5;
}

/* =============================================
   APP LAYOUT
   ============================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* — Sidebar — */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-dark);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    height: var(--header-height);
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid var(--border-dark);
    box-sizing: border-box;
}

.sidebar-brand h2 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-brand span {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
    margin-top: 3px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-nav {
    flex: 1;
    padding: 0.85rem 0.75rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1.75rem;
}

.nav-section-title {
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.4rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.52rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 1px;
}

.nav-link:hover {
    background: var(--ivory-dark);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--slate-dark);
    color: var(--ivory-light);
    font-weight: 600;
}

.nav-link .icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: 0.6;
}

.nav-link.active .icon {
    opacity: 1;
}

.nav-link:hover .icon {
    opacity: 0.9;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-dark);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem;
}

.sidebar-user .avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--slate-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--ivory-light);
    flex-shrink: 0;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-name {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-role {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* — Main Content — */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-primary);
}

.main-header {
    height: var(--header-height);
    background: var(--bg-header);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-left h1 {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 1px;
    background: var(--border-dark);
    border-radius: var(--radius-md);
    padding: 2px;
    border: 1px solid var(--border-dark);
}

.lang-btn {
    padding: 3px 11px;
    border-radius: 5px;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    letter-spacing: 0.02em;
}

.lang-btn:hover {
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--slate-dark);
    color: var(--ivory-light);
}

.content-area {
    padding: 1.75rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* =============================================
   COMPONENTS
   ============================================= */

/* — Cards — */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition-slow);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 1.35rem;
}

.card-footer {
    padding: 0.9rem 1.35rem;
    border-top: 1px solid var(--border);
    background: var(--ivory-light);
}

/* — Stat Cards — */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.35rem;
    transition: var(--transition-slow);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: var(--slate-faded-20);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.stat-label {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-icon {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.25rem;
    opacity: 0.08;
}

/* — Buttons — */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.52rem 1.15rem;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.855rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
    letter-spacing: 0;
}

/* Primary — Anthropic dark-filled */
.btn-primary {
    background: var(--slate-dark);
    color: var(--ivory-light);
    border-color: var(--slate-dark);
}

.btn-primary:hover {
    background: var(--slate-medium);
    border-color: var(--slate-medium);
    color: var(--ivory-light);
}

/* Secondary — outlined */
.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-dark);
}

.btn-secondary:hover {
    background: var(--ivory-dark);
    border-color: var(--slate-faded-20);
    color: var(--text-primary);
}

/* Success */
.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success-dark);
}

.btn-success:hover {
    background: var(--success-dark);
    color: white;
}

/* Danger */
.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

/* Warning */
.btn-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning-dark);
}

.btn-sm {
    padding: 0.28rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 5px;
}

.btn-lg {
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
}

.btn-block {
    width: 100%;
}

/* — Forms — */
.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    letter-spacing: 0.01em;
}

.form-control {
    width: 100%;
    padding: 0.58rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--slate-medium);
    box-shadow: 0 0 0 3px var(--slate-faded-10);
}

.form-control::placeholder {
    color: var(--cloud-medium);
}

select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23b0aea5' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.15em;
    padding-right: 2.5rem;
}

.form-error {
    color: var(--danger);
    font-family: var(--font-sans);
    font-size: 0.76rem;
    margin-top: 0.25rem;
}

/* — Tables — */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 0.65rem 1.1rem;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    background: var(--ivory-light);
    border-bottom: 1px solid var(--border-dark);
}

td {
    padding: 0.72rem 1.1rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

tr:hover td {
    background: var(--ivory-light);
}

tr:last-child td {
    border-bottom: none;
}

/* — Badges — */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-full);
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.badge-success {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.badge-info {
    background: var(--info-light);
    color: var(--info-dark);
}

.badge-secondary {
    background: var(--ivory-dark);
    color: var(--text-muted);
    border: 1px solid var(--border-dark);
}

/* — Relevance Bar — */
.relevance-bar {
    width: 64px;
    height: 4px;
    background: var(--border-dark);
    border-radius: var(--radius-full);
    overflow: hidden;
    display: inline-flex;
    vertical-align: middle;
    margin-left: 0.4rem;
}

.relevance-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.relevance-high   { background: var(--success); }
.relevance-medium { background: var(--clay); }
.relevance-low    { background: var(--danger); }

/* — Policy Card — */
.policy-card {
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    transition: var(--transition-slow);
    cursor: pointer;
    position: relative;
}

.policy-card:hover {
    border-color: var(--slate-faded-20);
    box-shadow: var(--shadow-md);
}

.policy-card.unread::before {
    content: '';
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: 7px;
    height: 7px;
    background: var(--clay);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.4); opacity: 0.5; }
}

.policy-card .category-tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    background: var(--ivory-medium);
    color: var(--slate-medium);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 600;
    margin-bottom: 0.65rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid var(--border-dark);
}

.policy-card h3 {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    line-height: 1.4;
    color: var(--text-primary);
}

.policy-card p {
    font-family: var(--font-sans);
    color: var(--text-secondary);
    font-size: 0.855rem;
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.policy-card .meta {
    margin-top: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.policies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* — Explanation Box — */
.explanation-box {
    background: var(--ivory-medium);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    margin-top: 1.5rem;
}

.explanation-box h4 {
    font-family: var(--font-serif);
    color: var(--text-primary);
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
}

.explanation-box p {
    font-family: var(--font-sans);
    color: var(--text-secondary);
    line-height: 1.85;
    font-size: 0.9rem;
}

/* — Alerts — */
.alert {
    padding: 0.8rem 1.1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.1rem;
    font-family: var(--font-sans);
    font-size: 0.855rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: var(--success-light);
    color: var(--success-dark);
    border: 1px solid #a8d5b5;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger-dark);
    border: 1px solid #f0b8b8;
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
    border: 1px solid #fde68a;
}

.alert-info {
    background: var(--info-light);
    color: var(--info-dark);
    border: 1px solid #a9c8e8;
}

/* — Pagination — */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.75rem;
    padding: 1rem 0;
    list-style: none;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 0.65rem;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.855rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-dark);
}

.pagination a:hover {
    background: var(--slate-dark);
    color: var(--ivory-light);
    border-color: var(--slate-dark);
}

.pagination .active span {
    background: var(--slate-dark);
    color: var(--ivory-light);
    border: 1px solid var(--slate-dark);
    font-weight: 600;
}

.pagination .disabled span {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: not-allowed;
    opacity: 0.45;
}

/* — Empty State — */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
}

.empty-state .icon {
    font-size: 2.25rem;
    margin-bottom: 0.75rem;
    opacity: 0.35;
}

.empty-state h3 {
    font-family: var(--font-serif);
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-size: 1rem;
}

.empty-state p {
    font-family: var(--font-sans);
    color: var(--text-muted);
    font-size: 0.855rem;
    margin-bottom: 1.25rem;
}

/* — Filter Bar — */
.filter-bar {
    display: flex;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.filter-bar .form-control {
    max-width: 280px;
}

/* — Mobile Toggle — */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 19, 0.35);
    z-index: 99;
}

/* — File Upload — */
.file-upload {
    border: 1px dashed var(--border-dark);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--ivory-light);
}

.file-upload:hover {
    border-color: var(--slate-medium);
    background: var(--ivory-medium);
}

.file-upload input[type="file"] {
    display: none;
}

.file-upload .upload-icon {
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 0.65rem;
}

.file-upload p {
    font-family: var(--font-sans);
    color: var(--text-secondary);
    font-size: 0.855rem;
}

.file-upload .file-name {
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 0.4rem;
}

/* — Spinner — */
.spinner {
    width: 17px;
    height: 17px;
    border: 2px solid var(--border-dark);
    border-top-color: var(--slate-dark);
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================
   UTILITIES
   ============================================= */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.25rem; }

.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 0.82rem; font-family: var(--font-sans); }

/* =============================================
   MOBILE BOTTOM NAV
   ============================================= */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--white);
        border-top: 1px solid var(--border-dark);
        z-index: 100;
        box-shadow: 0 -2px 12px rgba(20, 20, 19, 0.07);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        text-decoration: none;
        color: var(--text-muted);
        font-family: var(--font-sans);
        font-size: 0.65rem;
        font-weight: 500;
        letter-spacing: 0.01em;
        transition: color 0.15s ease;
        padding: 0 0.25rem;
    }

    .bottom-nav-item svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .bottom-nav-item.active,
    .bottom-nav-item:hover {
        color: var(--slate-dark);
    }

    /* Push page content above bottom nav */
    .main-content {
        padding-bottom: 60px;
    }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-toggle {
        display: block;
    }

    .content-area {
        padding: 1.1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .policies-grid {
        grid-template-columns: 1fr;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar .form-control {
        max-width: 100%;
    }

    .auth-inner {
        max-width: 100%;
    }

    /* Auth hero mobile */
    .auth-screen {
        flex-direction: column;
    }

    .auth-hero {
        flex: 0 0 auto;
        border-right: none;
        border-bottom: none;
        padding: 6rem 1.5rem 0.5rem;
        justify-content: flex-start;
    }

    .auth-hero-title {
        font-size: 2.8rem;
    }

    .auth-panel {
        flex: 1;
        padding: 0.5rem 1.5rem 3rem;
        align-items: center;
        justify-content: center;
        background: var(--bg-primary);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-right {
        gap: 0.5rem;
    }
}

/* ─────────────────────────────────────────
   Settings / Profile multi-level pages
───────────────────────────────────────── */
.settings-page {
    max-width: 560px;
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0 1.5rem;
}

.settings-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--slate-dark);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    flex-shrink: 0;
    letter-spacing: 0;
}

.settings-user-info {
    flex: 1;
    min-width: 0;
}

.settings-user-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-dark);
}

.settings-user-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-role-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--slate-dark);
    color: var(--white);
    flex-shrink: 0;
}

.settings-divider {
    border: none;
    border-top: 1px solid var(--border-dark);
    margin: 0;
}

.settings-group-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 1.25rem 0 0.5rem;
}

.settings-nav-list {
    display: flex;
    flex-direction: column;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-dark);
    font-size: 0.9rem;
    transition: color 0.12s;
}

.settings-nav-item:last-child {
    border-bottom: none;
}

.settings-nav-item:hover {
    color: var(--slate-dark);
}

.settings-nav-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    flex-shrink: 0;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-nav-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ── Subpage ── */
.settings-subpage {
    max-width: 560px;
    margin: 0 auto;
    padding: 0 1rem 4rem;
}

.settings-back-bar {
    padding: 0.75rem 0 0.5rem;
}

.settings-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.12s;
}

.settings-back-link:hover {
    color: var(--slate-dark);
}

.settings-back-link svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.settings-subpage-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-dark);
    padding: 0.25rem 0 1rem;
}

.settings-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.settings-item:last-of-type {
    border-bottom: none;
}

.settings-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.settings-input,
.settings-select {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    font-size: 0.925rem;
    color: var(--text-dark);
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
}

.settings-select {
    cursor: pointer;
}

.settings-form-footer {
    padding-top: 1.25rem;
}

/* ── Language radio list ── */
.settings-radio-list {
    display: flex;
    flex-direction: column;
}

.settings-radio-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.settings-radio-label:last-child {
    border-bottom: none;
}

.settings-radio-label input[type="radio"] {
    display: none;
}

.settings-radio-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border-dark);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.12s;
}

.settings-radio-label input[type="radio"]:checked ~ .settings-radio-check {
    border-color: var(--slate-dark);
    background: var(--slate-dark);
    box-shadow: inset 0 0 0 3px var(--white);
}

/* Logout button */
.settings-logout-btn {
    width: 100%;
    padding: 0.85rem;
    margin-top: 0.75rem;
    background: transparent;
    border: 1.5px solid var(--border-dark);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--danger-dark);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    text-align: center;
}

.settings-logout-btn:hover {
    background: var(--danger-light);
    border-color: var(--danger-dark);
}
