:root {
    --brand-primary: #003a78;
    --brand-primary-dark: #002a5c;
    --brand-accent: #ffc20e;
    --brand-accent-dark: #e0a800;
    --text-strong: #0f172a;
    --text-muted: #5b6473;
    --surface: #ffffff;
    --surface-muted: #f5f7fb;
    --border: #e3e8ef;
    --border-strong: #cdd6df;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 6px 24px rgba(15, 23, 42, .08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--text-strong);
    background: linear-gradient(180deg, #eef2f9 0%, #f6f8fc 320px, #f6f8fc 100%);
    margin: 0;
    line-height: 1.5;
    font-size: 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-dark); text-decoration: underline; }

/* ---------- Header ---------- */
.app-header {
    background: linear-gradient(120deg, var(--brand-primary) 0%, #024d9d 55%, #0c6cba 100%);
    color: #fff;
    padding: 28px 0 28px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.app-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(255,194,14,.18), transparent 45%);
    pointer-events: none;
}
.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand-logo {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--brand-accent);
    color: var(--brand-primary);
    display: grid; place-items: center;
    font-weight: 800; font-size: 18px;
    box-shadow: var(--shadow);
}
.brand-text { line-height: 1.15; }
.brand-text .title { font-weight: 700; font-size: 17px; }
.brand-text .subtitle { font-size: 12px; opacity: .85; letter-spacing: .04em; text-transform: uppercase; }

.app-header h1 {
    margin: 28px 0 6px;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.app-header .lede {
    margin: 0;
    color: rgba(255,255,255,.85);
    max-width: 700px;
}

/* ---------- Containers ---------- */
.container {
    width: 100%;
    max-width: 1080px;
    padding: 0 20px;
    margin: 0 auto;
}
.main {
    margin-top: 0;
    padding-top: 28px;
    padding-bottom: 56px;
    position: relative;
    z-index: 2;
    flex: 1;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fbfcfe 0%, #f6f8fc 100%);
    display: flex;
    align-items: center;
    gap: 12px;
}
.card-header h2,
.card-header .card-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-strong);
}
.card-header .badge {
    margin-left: auto;
}
.card-body { padding: 24px; }

/* ---------- Stepper ---------- */
.stepper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 24px;
    flex-wrap: wrap;
}
.step {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}
.step .num {
    width: 28px; height: 28px; border-radius: 50%;
    background: #fff; color: var(--text-muted);
    display: grid; place-items: center;
    font-weight: 700; font-size: 13px;
    border: 1.5px solid var(--border-strong);
}
.step.active { color: #fff; }
.step.active .num {
    background: var(--brand-accent); color: var(--brand-primary);
    border-color: var(--brand-accent);
}
.step.done { color: rgba(255,255,255,.95); }
.step.done .num {
    background: rgba(255,255,255,.18); color: #fff;
    border-color: rgba(255,255,255,.35);
}
.step-divider {
    width: 36px; height: 2px;
    background: rgba(255,255,255,.25);
    border-radius: 1px;
}
.step-divider.done { background: var(--brand-accent); }

/* ---------- Forms ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px 20px;
}
.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }
@media (max-width: 768px) {
    .col-8, .col-6, .col-4, .col-3 { grid-column: span 12; }
}

.field { display: flex; flex-direction: column; }
.field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-strong);
    margin-bottom: 6px;
}
.field label .req { color: var(--danger); margin-left: 2px; }
.field .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}
.field .error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 6px;
    display: none;
}
.field.has-error .error { display: block; }
.field.has-error .input,
.field.has-error select,
.field.has-error textarea { border-color: var(--danger); }

.input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text-strong);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 58, 120, .12);
}
textarea { resize: vertical; min-height: 90px; }

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20'%3E%3Cpath fill='%2364748b' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center; justify-content: center; gap: 8px;
    padding: 11px 22px;
    font-size: 14px; font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s ease;
    font-family: inherit;
    line-height: 1.2;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--brand-primary-dark);
    color: #fff;
    text-decoration: none;
}
.btn-accent {
    background: var(--brand-accent);
    color: var(--brand-primary);
}
.btn-accent:hover:not(:disabled) {
    background: var(--brand-accent-dark);
    color: var(--brand-primary);
    text-decoration: none;
}
.btn-ghost {
    background: #fff;
    color: var(--brand-primary);
    border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-muted);
    color: var(--brand-primary);
    text-decoration: none;
}
.btn-danger {
    background: #fee2e2;
    color: var(--danger);
}
.btn-sm { padding: 7px 14px; font-size: 13px; }

.form-actions {
    display: flex; gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    display: flex; align-items: flex-start; gap: 12px;
    font-size: 14px;
    border: 1px solid;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-muted   { background: #e2e8f0; color: #475569; }

/* ---------- Fieldset / Section ---------- */
.section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    background: #fcfdff;
}
.section-title {
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; font-weight: 700;
    color: var(--brand-primary);
    margin: 0 0 16px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.section-title::before {
    content: '';
    width: 4px; height: 18px;
    background: var(--brand-accent);
    border-radius: 2px;
}

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}
.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th {
    background: var(--surface-muted);
    color: var(--text-strong);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.table tbody tr:hover { background: #fafbfd; }
.table .actions { text-align: right; }

/* ---------- File upload ---------- */
.file-uploader {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fafbfd;
    cursor: pointer;
    transition: all .15s;
}
.file-uploader:hover { border-color: var(--brand-primary); background: #f4f7fc; }
.file-uploader.has-file { border-style: solid; border-color: var(--success); background: #f0fdf4; }
.file-uploader input[type=file] {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
    opacity: 0;
}
.file-uploader .icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--brand-primary);
    color: #fff;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.file-uploader.has-file .icon { background: var(--success); }
.file-uploader .label { font-weight: 600; font-size: 14px; color: var(--text-strong); }
.file-uploader .sub { font-size: 12px; color: var(--text-muted); }
.file-uploader .remove-file {
    margin-left: auto; color: var(--danger); cursor: pointer;
    background: none; border: none; font-size: 13px; font-weight: 600;
    padding: 6px 10px; border-radius: 6px;
}
.file-uploader .remove-file:hover { background: #fee2e2; }
.file-uploader .spinner {
    display: none; width: 16px; height: 16px;
    border: 2px solid #e2e8f0; border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.file-uploader.uploading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Autocomplete ---------- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 4px;
    box-shadow: var(--shadow);
    max-height: 280px; overflow: auto;
    z-index: 10;
    display: none;
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.highlight { background: var(--surface-muted); }
.autocomplete-item small { color: var(--text-muted); display: block; margin-top: 2px; font-size: 12px; }

/* ---------- Project info pill ---------- */
.project-info {
    display: flex; align-items: center; gap: 12px;
    background: #f0f7ff;
    border: 1px solid #cfe2ff;
    color: var(--brand-primary-dark);
    padding: 12px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.project-info .label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; opacity: .75; }
.project-info .value { font-size: 16px; font-weight: 600; }
.project-info .meta { font-size: 13px; color: var(--text-muted); }

/* ---------- Footer ---------- */
.app-footer {
    padding: 22px 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: #fff;
}

/* ---------- Helpers ---------- */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0 !important; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.d-none { display: none !important; }

@media (max-width: 600px) {
    .app-header { padding-bottom: 24px; }
    .app-header h1 { font-size: 24px; }
    .card-body { padding: 18px; }
    .card-header { padding: 14px 18px; }
}
