@import url("fonts.css");

:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-muted: #f8fafc;
    --text: #172033;
    --muted: #657089;
    --line: #dfe5ef;
    --line-soft: #edf1f7;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --danger: #dc2626;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.10), transparent 32rem),
        linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
}

a {
    color: var(--primary);
    text-decoration: none;
}

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

.app-shell {
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    width: min(1180px, calc(100% - 2rem));
    margin: 1rem auto 0;
    padding: 0.75rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 190px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, #1d4ed8, #0f766e);
    font-weight: 800;
    letter-spacing: 0;
}

.brand-mark:hover {
    color: #fff;
    text-decoration: none;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.1;
}

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

.main-nav {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 2.35rem;
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    color: #334155;
    font-weight: 650;
}

.main-nav a:hover {
    background: #eef4ff;
    color: var(--primary-dark);
    text-decoration: none;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
}

.user-menu form {
    margin: 0;
}

.content {
    width: min(1180px, calc(100% - 2rem));
    margin: 1rem auto 2rem;
}

.page-panel {
    padding: clamp(1rem, 2vw, 1.5rem);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

h1,
h2,
h3 {
    margin: 0 0 1rem;
    line-height: 1.2;
    color: #0f172a;
}

h1 {
    font-size: clamp(1.65rem, 2.2vw, 2.1rem);
    letter-spacing: 0;
}

h2 {
    margin-top: 1.5rem;
    font-size: 1.2rem;
}

p {
    margin: 0 0 1rem;
}

.btn,
button.btn,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.35rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.btn:hover,
button.btn:hover,
input[type="submit"]:hover {
    background: var(--primary-dark);
    color: #fff;
    text-decoration: none;
}

.btn-secondary {
    background: #fff;
    color: #334155;
    border-color: var(--line);
    box-shadow: none;
}

.btn-secondary:hover {
    background: #f8fafc;
    color: #0f172a;
}

.btn-danger {
    background: var(--danger);
    box-shadow: 0 8px 18px rgba(220, 38, 38, 0.16);
}

.btn-danger:hover {
    background: #b91c1c;
}

form {
    margin: 0 0 1rem;
}

form[method="get"] {
    display: flex;
    align-items: end;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.9rem;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--panel-muted);
}

label {
    display: inline-flex;
    flex-direction: column;
    gap: 0.35rem;
    color: #334155;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 2.35rem;
    padding: 0.48rem 0.65rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    min-height: 7rem;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(37, 99, 235, 0.14);
}

form p {
    margin: 0 0 0.85rem;
}

form p label {
    display: flex;
}

table {
    width: 100%;
    min-width: 680px;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

th,
td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
    vertical-align: top;
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #f8fbff;
}

tr:last-child td,
tbody tr:last-child td {
    border-bottom: 0;
}

.inactive {
    color: #94a3b8;
    background: #f8fafc;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.6rem;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.badge-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-inactive {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.messages {
    display: grid;
    gap: 0.6rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.messages li {
    padding: 0.75rem 0.9rem;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    font-weight: 650;
}

.errorlist {
    margin: 0 0 1rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #991b1b;
    list-style-position: inside;
}

.form-error {
    margin: 0 0 1rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-weight: 650;
}

@media (max-width: 820px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .brand {
        min-width: 0;
    }

    .main-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .main-nav a {
        justify-content: center;
    }

    .user-menu {
        justify-content: space-between;
        white-space: normal;
    }

    form[method="get"] {
        align-items: stretch;
        flex-direction: column;
    }

    form[method="get"] .btn,
    form[method="get"] button {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .topbar,
    .content {
        width: calc(100% - 1rem);
    }

    .main-nav {
        grid-template-columns: 1fr;
    }

    .page-panel {
        padding: 0.85rem;
    }

    .user-menu {
        align-items: stretch;
        flex-direction: column;
    }
}
