:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --border: #e5e7eb;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
    --radius: 22px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 36rem),
        var(--bg);
    color: var(--text);
}

.app-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 36px;
    margin-bottom: 20px;
    border-radius: 32px;
    color: white;
    background: linear-gradient(135deg, #172033, #2563eb);
    box-shadow: var(--shadow);
}

.admin-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    text-align: right;
}

.admin-status span {
    color: rgba(255,255,255,0.82);
    font-weight: 800;
}

.hero-btn {
    color: var(--text);
    text-decoration: none;
    background: rgba(255,255,255,0.92);
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    opacity: 0.75;
}

h1, h2, p { margin-top: 0; }

h1 {
    margin-bottom: 8px;
    font-size: clamp(2.4rem, 7vw, 4.8rem);
    line-height: 0.95;
    letter-spacing: -0.08em;
}

.subtitle {
    max-width: 620px;
    margin-bottom: 0;
    color: rgba(255,255,255,0.82);
}

.panel {
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.75);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.86);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.read-mode-panel {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--muted);
}

.read-mode-panel strong {
    color: var(--text);
}

.admin-only,
.admin-only-cell {
    display: none;
}

.is-admin .admin-only {
    display: block;
}

.is-admin .toolbar-actions.admin-only {
    display: flex;
}

.is-admin .admin-only-cell {
    display: table-cell;
}

.is-admin .read-mode-panel {
    display: none;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

label span {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
    color: var(--muted);
}

input, select {
    width: 100%;
    min-height: 46px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 14px;
    font: inherit;
    color: var(--text);
    background: white;
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}

button, .secondary-btn {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

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

.primary-btn:hover { background: var(--primary-dark); }

.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    background: #eef2ff;
}

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

.danger-btn:hover { background: var(--danger-dark); }

.file-btn input { display: none; }

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.toolbar h2 { margin-bottom: 4px; }
.toolbar p { margin-bottom: 0; color: var(--muted); }

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-actions.admin-only {
    display: none;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th, td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    font-size: 0.86rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.filters th {
    padding-top: 0;
}

.filters select {
    min-height: 38px;
    border-radius: 10px;
}

.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    text-decoration: none;
    color: white;
    background: var(--primary);
    font-weight: 900;
    box-shadow: 0 8px 20px rgba(37,99,235,0.25);
}

.icon-link:hover {
    background: var(--primary-dark);
}

.delete-btn {
    padding: 9px 12px;
    color: var(--danger);
    background: #fee2e2;
}

.empty-state {
    display: none;
    margin: 18px 0 0;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 860px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-status {
        justify-content: flex-start;
        text-align: left;
    }
}

@media (max-width: 620px) {
    .app-shell {
        width: min(100% - 20px, 1120px);
        padding: 16px 0;
    }

    .hero, .panel {
        padding: 20px;
        border-radius: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 16px;
    }

    table {
        min-width: 760px;
    }

    th, td {
        white-space: nowrap;
    }

    td:nth-child(3) {
        white-space: normal;
        min-width: 180px;
    }

    .filters select {
        min-width: 120px;
    }
}
