:root {
    --bg-base: #eef4f6;
    --surface: #ffffff;
    --surface-alt: #f7fbfc;
    --ink: #102333;
    --muted: #5f7481;
    --line: #d4e0e7;
    --primary: #0f766e;
    --primary-hover: #0d615b;
    --danger: #b42336;
    --danger-bg: #fff0f1;
    --success: #1f7a4f;
    --success-bg: #edf9f2;
    --warn: #946200;
    --warn-bg: #fff6dd;
    --shadow-soft: 0 10px 28px rgba(12, 38, 56, 0.08);
    --shadow-strong: 0 18px 36px rgba(9, 34, 54, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Plus Jakarta Sans", "Avenir Next", "Helvetica Neue", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1300px 700px at -10% -10%, #d6ebe2 0%, transparent 60%),
        radial-gradient(900px 500px at 110% 0%, #d7e6f4 0%, transparent 58%),
        linear-gradient(180deg, #f3f8fa 0%, var(--bg-base) 55%, #edf2f5 100%);
}

body::before,
body::after {
    content: "";
    position: fixed;
    pointer-events: none;
    z-index: -1;
}

body::before {
    width: min(38vw, 460px);
    height: min(38vw, 460px);
    left: -140px;
    top: 18vh;
    background: radial-gradient(circle at 32% 32%, rgba(15, 118, 110, 0.2), rgba(15, 118, 110, 0));
}

body::after {
    width: min(40vw, 480px);
    height: min(40vw, 480px);
    right: -180px;
    top: 8vh;
    background: radial-gradient(circle at 35% 35%, rgba(27, 104, 174, 0.18), rgba(27, 104, 174, 0));
}

h1,
h2,
h3 {
    font-family: "Space Grotesk", "Avenir Next", sans-serif;
    margin: 0 0 0.65rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

h1 {
    font-size: clamp(1.45rem, 1.2rem + 1.05vw, 2.05rem);
}

h2 {
    font-size: clamp(1.15rem, 1.02rem + 0.58vw, 1.45rem);
}

p {
    margin: 0 0 0.8rem;
}

a {
    color: #0d5a86;
    text-underline-offset: 2px;
}

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

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.95rem 1.35rem;
    border-bottom: 1px solid rgba(167, 191, 203, 0.35);
    background: rgba(248, 252, 253, 0.82);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 8px 24px rgba(10, 39, 59, 0.06);
    animation: header-in 0.45s ease-out both;
}

.brand-wrap {
    display: grid;
    gap: 0.15rem;
}

.brand {
    font-family: "Space Grotesk", "Avenir Next", sans-serif;
    font-size: 1.06rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.52rem;
    letter-spacing: 0.01em;
}

.brand::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(130deg, #0f766e, #1c8eb2);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
}

.brand-tag {
    color: var(--muted);
    font-size: 0.69rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header-user {
    border: 1px solid #c5d7e2;
    background: #f6fbff;
    color: #12334a;
    border-radius: 999px;
    padding: 0.38rem 0.7rem;
    font-size: 0.79rem;
    font-weight: 700;
    white-space: nowrap;
}

.main-nav {
    display: flex;
    gap: 0.42rem;
    flex-wrap: wrap;
}

.main-nav a {
    text-decoration: none;
    color: var(--ink);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.48rem 0.78rem;
    font-size: 0.9rem;
    font-weight: 600;
    transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.main-nav a:hover {
    border-color: #bfd1dd;
    background: rgba(17, 97, 134, 0.08);
    transform: translateY(-1px);
}

.main-nav a.active {
    border-color: #abc3d2;
    background: linear-gradient(120deg, #e2f2ee, #e0edf8);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.main-nav a[href$="/logout.php"] {
    border-color: #ebc7cd;
    background: #fff2f2;
    color: #9c2333;
}

.main-nav a[href$="/logout.php"]:hover {
    border-color: #ddadbb;
    background: #ffe8eb;
}

.app-main {
    width: min(1180px, 94vw);
    margin: 1.35rem auto 2.5rem;
    display: grid;
    gap: 1.15rem;
}

.app-main > * {
    opacity: 0;
    transform: translateY(14px);
    animation: card-in 0.52s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
}

.app-main > *:nth-child(1) {
    animation-delay: 0.05s;
}

.app-main > *:nth-child(2) {
    animation-delay: 0.1s;
}

.app-main > *:nth-child(3) {
    animation-delay: 0.15s;
}

.app-main > *:nth-child(4) {
    animation-delay: 0.2s;
}

.app-main > *:nth-child(5) {
    animation-delay: 0.25s;
}

.app-main > *:nth-child(6) {
    animation-delay: 0.3s;
}

.card {
    position: relative;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(247, 252, 253, 0.96));
    border: 1px solid rgba(164, 188, 201, 0.45);
    border-radius: 18px;
    padding: 1.15rem 1.2rem;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: linear-gradient(90deg, #0f766e, #1d87b9, #df9852);
}

.card.narrow {
    width: min(600px, 94vw);
    margin-inline: auto;
}

.sub-card {
    border: 1px solid #d6e4ec;
    border-radius: 14px;
    padding: 0.95rem;
    background: var(--surface-alt);
}

.muted {
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 0.85rem;
}

.spaced-top {
    margin-top: 1rem;
}

.spaced-bottom {
    margin-bottom: 1rem;
}

.grid {
    display: grid;
    gap: 0.8rem;
}

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

label {
    display: grid;
    gap: 0.36rem;
    font-weight: 600;
    font-size: 0.9rem;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    border: 1px solid #c8d7e0;
    border-radius: 12px;
    padding: 0.62rem 0.78rem;
    background: #ffffff;
    color: var(--ink);
    box-shadow: inset 0 1px 2px rgba(12, 31, 49, 0.05);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

input:focus,
select:focus,
button:focus {
    outline: 3px solid rgba(15, 118, 110, 0.22);
    outline-offset: 1px;
}

input:focus,
select:focus {
    border-color: #1f8a82;
    box-shadow: 0 0 0 1px rgba(31, 138, 130, 0.34), inset 0 1px 2px rgba(12, 31, 49, 0.03);
}

button,
.button-link {
    border: 1px solid transparent;
    background: linear-gradient(135deg, var(--primary), #1b8aa6);
    color: #ffffff;
    border-radius: 12px;
    padding: 0.56rem 0.96rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 8px 20px rgba(16, 100, 120, 0.2);
    transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

button:hover,
.button-link:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow: 0 11px 22px rgba(16, 100, 120, 0.24);
}

button:disabled {
    background: #9fb3bf;
    box-shadow: none;
    cursor: not-allowed;
}

.button-link.ghost {
    background: #f7fbfd;
    color: var(--ink);
    border-color: #c3d5e0;
    box-shadow: none;
}

.button-link.ghost:hover {
    background: #f1f7fb;
    border-color: #adc4d3;
    box-shadow: none;
}

.inline-form {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
    margin: 0;
    flex-wrap: wrap;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.full {
    grid-column: 1 / -1;
}

.alert {
    border-radius: 14px;
    padding: 0.72rem 0.86rem;
    border: 1px solid;
    margin-bottom: 0.85rem;
}

.alert.error {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: #f2c7cf;
}

.alert.success {
    color: var(--success);
    background: var(--success-bg);
    border-color: #c6ead4;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.77rem;
    border-radius: 999px;
    border: 1px solid #bcd0dc;
    color: #24465a;
    background: #edf5fa;
    padding: 0.16rem 0.56rem;
    font-weight: 600;
}

.chip.ok {
    color: var(--success);
    background: var(--success-bg);
    border-color: #b9e4c9;
}

.chip.warn {
    color: var(--warn);
    background: var(--warn-bg);
    border-color: #efd89f;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

th,
td {
    padding: 0.68rem 0.6rem;
    border-bottom: 1px solid #e2ebf1;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

thead th {
    color: var(--muted);
    font-size: 0.77rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: #f4fafc;
    font-weight: 700;
}

tbody tr:hover {
    background: #f7fcfe;
}

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

td.allow-wrap {
    white-space: normal;
    min-width: 260px;
    word-break: break-word;
}

.clean-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.62rem;
}

.clean-list li {
    border: 1px solid #d8e5ec;
    border-radius: 12px;
    padding: 0.62rem 0.72rem;
    background: #fbfeff;
}

.permission-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 600;
}

.checkbox-inline input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

@keyframes header-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.996);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 980px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-right {
        width: 100%;
        justify-content: flex-start;
    }

    .main-nav {
        width: 100%;
    }

    .header-user {
        order: -1;
    }
}

@media (max-width: 820px) {
    .grid.cols-2 {
        grid-template-columns: 1fr;
    }

    .app-main {
        width: min(96vw, 1180px);
        margin-top: 1rem;
    }

    th,
    td {
        padding: 0.58rem 0.48rem;
    }
}

@media (max-width: 560px) {
    .app-header {
        padding: 0.8rem 0.9rem;
    }

    .card {
        border-radius: 16px;
        padding: 0.95rem;
    }

    .main-nav a {
        font-size: 0.86rem;
        padding: 0.44rem 0.67rem;
    }

    .header-user {
        font-size: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
