@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Sora:wght@500;600;700&display=swap");

:root {
    --bg: #eef3f0;
    --surface: #ffffff;
    --surface-soft: #f7faf8;
    --text: #14241c;
    --muted: #66786e;
    --border: #d7e3db;
    --brand: #0d7a56;
    --brand-dark: #095c40;
    --brand-soft: #e5f5ee;
    --ok-bg: #e5f7ec;
    --ok-text: #0f6b3f;
    --err-bg: #fdecec;
    --err-text: #a11d1d;
    --shadow: 0 12px 40px rgba(20, 36, 28, 0.08);
    --shadow-lg: 0 24px 60px rgba(20, 36, 28, 0.14);
    --radius: 18px;
    --font: "Manrope", sans-serif;
    --display: "Sora", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(1000px 420px at -5% -10%, #cfe8db 0%, transparent 55%),
        radial-gradient(800px 380px at 110% 0%, #dce8e2 0%, transparent 45%),
        linear-gradient(180deg, #f5f8f6 0%, var(--bg) 100%);
}

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

button,
input,
select {
    font: inherit;
}

.shell {
    width: min(100%, calc(100% - 1.5rem));
    max-width: none;
    margin: 0 auto;
    padding: 1rem 0.75rem 2rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.4rem;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(215, 227, 219, 0.9);
    border-radius: 20px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-logo {
    height: 44px;
    width: auto;
    display: block;
    object-fit: contain;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #fff;
    font-family: var(--display);
    font-weight: 700;
    font-size: 0.95rem;
    background: linear-gradient(145deg, #129567, #0a5c40);
    box-shadow: 0 8px 18px rgba(13, 122, 86, 0.28);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.brand-copy strong {
    font-family: var(--display);
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.brand-copy span {
    color: var(--muted);
    font-size: 0.86rem;
}

.nav {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    align-items: center;
}

.nav a,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    padding: 0.58rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.18s ease;
}

.nav a:hover,
.btn:hover {
    color: var(--text);
    background: var(--brand-soft);
}

.nav a.active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 8px 18px rgba(13, 122, 86, 0.25);
}

.btn {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

.btn:hover {
    border-color: #b9d0c4;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-dark);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

.panel {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(215, 227, 219, 0.95);
    border-radius: 22px;
    box-shadow: var(--shadow);
    overflow: visible;
}

.panel-inner {
    border-radius: 22px;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem 1rem;
    padding: 1.15rem 1.2rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff, var(--surface-soft));
    border-radius: 22px 22px 0 0;
    position: relative;
    z-index: 5;
    align-items: end;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    min-height: 42px;
}

.filter-actions .btn {
    border-radius: 12px;
    padding: 0.72rem 1rem;
}

#content {
    border-radius: 0 0 22px 22px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.field > span {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 600;
}

input,
select {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.72rem 0.85rem;
    color: var(--text);
    background: #fff;
    transition: 0.15s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(13, 122, 86, 0.12);
}

.select-wrap select {
    width: 100%;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2366786e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.2rem;
}

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

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

th,
td {
    text-align: left;
    padding: 0.95rem 1.1rem;
    border-bottom: 1px solid #e8efe9;
    font-size: 0.93rem;
}

th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    background: #f8fbf9;
    font-weight: 700;
}

tbody tr {
    transition: background 0.15s ease;
}

tbody tr:hover td {
    background: #f5faf7;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.28rem 0.7rem;
    font-size: 0.76rem;
    font-weight: 700;
}

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

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

.footer-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.1rem;
    color: var(--muted);
    font-size: 0.88rem;
    background: #fbfcfb;
}

.pager {
    display: flex;
    gap: 0.45rem;
}

.empty,
.loading,
.error {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--muted);
}

.loading::before {
    content: "";
    width: 28px;
    height: 28px;
    margin: 0 auto 0.85rem;
    display: block;
    border-radius: 50%;
    border: 3px solid #d7e3db;
    border-top-color: var(--brand);
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error {
    color: var(--err-text);
}

.mono {
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.84rem;
}

/* Date picker */
.dp {
    position: relative;
}

.dp-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.72rem 0.85rem;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: 0.15s ease;
    text-align: left;
}

.dp-trigger:hover,
.dp.open .dp-trigger {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(13, 122, 86, 0.12);
}

.dp-trigger-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.dp-trigger-text strong {
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dp-trigger-text small {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.dp-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: var(--brand-soft);
    color: var(--brand);
}

.dp-panel {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    z-index: 40;
    width: min(320px, calc(100vw - 2rem));
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    padding: 0.85rem;
    display: none;
    animation: dpIn 0.16s ease;
}

.dp.dp-align-right .dp-panel {
    left: auto;
    right: 0;
}

.dp.open .dp-panel {
    display: block;
}

@keyframes dpIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dp-quick {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.dp-chip {
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--muted);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.dp-chip:hover,
.dp-chip.active {
    background: var(--brand-soft);
    border-color: #b7dfcb;
    color: var(--brand-dark);
}

.dp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.dp-month {
    font-family: var(--display);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-transform: capitalize;
}

.dp-nav-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.dp-nav-btn:hover {
    background: var(--brand-soft);
    border-color: #b7dfcb;
}

.dp-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.2rem;
    margin-bottom: 0.25rem;
}

.dp-week span {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    padding: 0.35rem 0;
    text-transform: uppercase;
}

.dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.dp-day {
    aspect-ratio: 1;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.dp-day:hover {
    background: var(--brand-soft);
}

.dp-day.muted {
    color: #a3b5ab;
    font-weight: 500;
}

.dp-day.today {
    box-shadow: inset 0 0 0 1.5px #9ecdb8;
}

.dp-day.selected {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 6px 14px rgba(13, 122, 86, 0.28);
}

.dp-day.selected:hover {
    background: var(--brand-dark);
}

.dp-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
}

.dp-foot .btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: "";
    position: absolute;
    inset: auto -10% -20% auto;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(18, 149, 103, 0.18), transparent 70%);
    pointer-events: none;
}

.login-card {
    width: min(420px, 100%);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(215, 227, 219, 0.95);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 2.1rem 1.6rem 1.7rem;
    backdrop-filter: blur(10px);
    position: relative;
}

.login-logo {
    display: block;
    height: 52px;
    width: auto;
    margin-bottom: 1.1rem;
    object-fit: contain;
}

.login-card .brand-mark {
    margin-bottom: 1rem;
}

.login-card h1 {
    margin: 0 0 0.35rem;
    font-family: var(--display);
    font-size: 1.7rem;
    letter-spacing: -0.03em;
}

.login-card p {
    margin: 0 0 1.5rem;
    color: var(--muted);
}

.login-card form {
    display: grid;
    gap: 0.95rem;
}

.login-card .btn {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
}

.login-card .error {
    padding: 0.4rem 0 0;
    text-align: left;
    font-size: 0.88rem;
}

/* Modal JSON */
body.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(14, 28, 21, 0.45);
    backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal {
    width: min(860px, 100%);
    max-height: min(86vh, 900px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fbf9;
}

.modal-head h2 {
    margin: 0;
    font-family: var(--display);
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.modal-sub {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.modal-head-actions {
    display: flex;
    gap: 0.45rem;
    flex-shrink: 0;
}

.modal-code {
    margin: 0;
    padding: 1rem 1.1rem;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #1c3228;
    background: #fcfefd;
    white-space: pre-wrap;
    word-break: break-word;
}

.btn-soft {
    background: var(--brand-soft);
    border-color: #b7dfcb;
    color: var(--brand-dark);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-soft:hover {
    background: #d7efe4;
}

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

    .nav {
        width: 100%;
    }

    .nav a,
    .nav .btn {
        flex: 1;
    }

    .dp-panel {
        left: auto;
        right: 0;
    }

    .modal-head {
        flex-direction: column;
    }
}
