:root {
    --card: rgba(255, 255, 255, 0.88);
    --ink: #171915;
    --muted: #676a60;
    --line: rgba(23, 25, 21, 0.08);
    --accent: #245d4c;
    --accent-2: #d4682e;
    --shadow: 0 24px 60px rgba(23, 25, 21, 0.08);
    --radius-xl: 28px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "IBM Plex Sans KR", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(36, 93, 76, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(212, 104, 46, 0.14), transparent 24%),
        linear-gradient(180deg, #f8f4ec 0%, #f3eee5 100%);
}

a { color: inherit; text-decoration: none; }

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

.admin-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 24px;
    margin-bottom: 20px;
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.58);
    box-shadow: var(--shadow);
}

.admin-header > div:first-child {
    flex: 1 1 320px;
    min-width: 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    max-width: 100%;
}

.brand strong {
    display: block;
    font-size: 18px;
}

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

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #173f34);
    color: #fff;
    font-weight: 700;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    flex: 1 1 560px;
    min-width: 0;
}

.admin-nav a {
    min-height: 42px;
    padding: 0 14px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: rgba(36, 93, 76, 0.08);
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}

.admin-nav a.has-payment-new {
    background: rgba(212, 104, 46, 0.14);
    color: #8a3f18;
}

.admin-new-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: #dc2f22;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 6px 16px rgba(220, 47, 34, 0.25);
}

.admin-main {
    display: grid;
    gap: 20px;
}

.card {
    border-radius: var(--radius-xl);
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 24px;
}

.hero-card {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-end;
}

.hero-card h1 {
    margin: 0 0 10px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.1;
}

.hero-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.8;
}

.hero-actions,
.inline-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.section-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 16px;
    border-radius: 14px;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
}

.button-primary { color: #fff; background: linear-gradient(135deg, var(--accent), #173f34); }
.button-secondary { color: var(--ink); background: rgba(36, 93, 76, 0.1); }
.button-warning { color: #fff; background: linear-gradient(135deg, var(--accent-2), #b54a15); }
.button-danger { color: #fff; background: linear-gradient(135deg, #8f2d14, #6e1d0f); }

.flash,
.setup-card {
    padding: 18px 20px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.8);
}

.flash-success { border-color: rgba(36, 93, 76, 0.18); background: rgba(36, 93, 76, 0.08); }
.flash-error { border-color: rgba(141, 45, 20, 0.2); background: rgba(141, 45, 20, 0.08); }

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.metric {
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--line);
    padding: 18px;
}

.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 8px; font-size: 30px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 16px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
th { font-size: 13px; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: rgba(36, 93, 76, 0.03); }

.site-empty-state {
    padding: 18px 20px;
    border-radius: 20px;
    background: rgba(36, 93, 76, 0.06);
    border: 1px solid var(--line);
}

.site-list-board {
    display: grid;
    gap: 12px;
}

.site-list-head,
.site-summary-grid {
    display: grid;
    grid-template-columns: 120px minmax(180px, 1.3fr) minmax(180px, 1.2fr) minmax(220px, 1.6fr) 140px 120px;
    gap: 14px;
    align-items: start;
}

.site-list-head {
    padding: 0 16px 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.site-list-row {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.84);
    padding: 16px;
}

.site-list-row.is-highlight {
    border-color: rgba(36, 93, 76, 0.34);
    box-shadow: 0 0 0 4px rgba(36, 93, 76, 0.08);
    background: rgba(244, 250, 247, 0.96);
}

.site-summary-item {
    min-width: 0;
}

.site-summary-item strong {
    display: block;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
}

.site-summary-action {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.site-modal {
    position: fixed;
    inset: 0;
    z-index: 5000;
}

.site-modal[hidden] {
    display: none;
}

.site-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(23, 25, 21, 0.45);
}

.site-modal-dialog {
    position: relative;
    width: min(1040px, calc(100% - 32px));
    max-height: calc(100vh - 48px);
    margin: 24px auto;
    overflow: auto;
    border-radius: 26px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 28px 80px rgba(23, 25, 21, 0.24);
    padding: 22px;
}

.site-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.site-modal-header h3 {
    margin: 0 0 6px;
    font-size: 24px;
    line-height: 1.2;
}

.site-modal-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.site-modal-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.site-detail-block {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--line);
    min-width: 0;
}

.site-detail-block h4 {
    margin: 0;
    font-size: 15px;
    line-height: 1.4;
}

.site-detail-block-wide {
    grid-column: 1 / -1;
}

.site-detail-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.site-detail-list > div {
    display: grid;
    gap: 4px;
}

.site-detail-list dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.site-detail-list dd {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.site-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    align-self: flex-start;
    gap: 10px;
    height: auto;
}

.site-card-actions form,
.site-card-actions a {
    flex: 0 0 auto;
    min-width: 0;
    height: auto;
    align-self: flex-start;
}

.site-card-actions .button {
    width: auto;
    min-width: 104px;
    height: 42px;
    min-height: 42px;
    max-height: 42px;
    padding: 0 14px;
    border-radius: 12px;
    align-self: flex-start;
    line-height: 1;
}

.site-card-actions a.button,
.site-card-actions button.button {
    display: inline-flex;
    flex: 0 0 auto;
}

.manual-renewal-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.manual-renewal-submit {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}

.manual-renewal-submit .button {
    min-width: 220px;
}

.payment-history-box {
    grid-column: 1 / -1;
    display: grid;
    gap: 12px;
    margin-top: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.payment-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.payment-history-head a {
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.payment-history-list {
    display: grid;
    gap: 10px;
}

.payment-history-item {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.74);
}

.payment-history-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.payment-history-item dl {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 14px;
    margin: 0;
}

.payment-history-item dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.payment-history-item dd {
    margin: 3px 0 0;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.payment-history-item p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

body.site-modal-opened {
    overflow: hidden;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-detail-button {
    border: 0;
    cursor: pointer;
    font-family: inherit;
}

.status-detail-button:hover,
.status-detail-button:focus-visible {
    box-shadow: 0 0 0 3px rgba(36, 93, 76, 0.16);
    outline: none;
}

.is-active { background: rgba(36, 93, 76, 0.12); color: var(--accent); }
.is-expired { background: rgba(141, 45, 20, 0.12); color: #7d2710; }
.is-warning { background: rgba(212, 104, 46, 0.12); color: #a94b18; }
.is-stopped { background: rgba(63, 66, 58, 0.12); color: #3f423a; }
.is-muted { background: rgba(103, 106, 96, 0.12); color: var(--muted); }

.usage-meter {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(23, 25, 21, 0.08);
    overflow: hidden;
    margin: 8px 0 6px;
}

.usage-meter > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.subtle {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

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

.field,
.field-wide {
    display: grid;
    gap: 8px;
}

.field-wide { grid-column: 1 / -1; }

label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

input[type="text"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(23, 25, 21, 0.1);
    background: rgba(255, 255, 255, 0.9);
    font-family: inherit;
    font-size: 14px;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.large-textarea {
    min-height: 420px;
    line-height: 1.8;
}

.recipient-preview {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.66);
}

.recipient-preview summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--accent);
}

.recipient-preview ul {
    display: grid;
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.recipient-preview li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(36, 93, 76, 0.06);
    font-size: 13px;
}

.recipient-preview span {
    color: var(--muted);
}

.section-title {
    margin: 0;
    font-size: 20px;
    line-height: 1.3;
}

.inline-actions form {
    margin: 0;
}

.inline-actions .button {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 12px;
}

.table-note-form {
    display: grid;
    gap: 8px;
    min-width: 220px;
}

.table-note-textarea {
    min-height: 108px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.6;
}

.table-note-submit {
    min-height: 40px;
    width: 100%;
}

.wallet-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.wallet-card {
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.84);
    padding: 20px;
}

.wallet-card-title {
    margin: 0 0 12px;
    font-size: 17px;
    line-height: 1.35;
}

.address-box {
    margin-top: 12px;
    padding: 14px 16px;
    border-radius: 18px;
    background: #171915;
    color: #faf9f6;
    font-family: Consolas, Monaco, monospace;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-all;
}

.copy-feedback {
    min-height: 20px;
    margin-top: 10px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}

.danger-confirm-form {
    display: grid;
    gap: 12px;
}

.danger-confirm-form .field {
    gap: 6px;
}

.danger-confirm-form input[type="text"],
.danger-confirm-form input[type="password"] {
    min-height: 42px;
    border-color: rgba(143, 45, 20, 0.22);
    background: rgba(255, 255, 255, 0.9);
}

.mono-text {
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-all;
}

.tx-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.copy-input-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex-wrap: wrap;
}

.copy-input-row-compact {
    min-width: 280px;
}

.copy-input {
    flex: 1 1 280px;
    min-width: 0;
    min-height: 42px;
}

.copy-input-row .button {
    flex: 0 0 auto;
}

.plan-transition-form {
    display: grid;
    gap: 10px;
    min-width: 220px;
}

.plan-transition-form .checkbox-row {
    padding: 0;
    gap: 10px;
}

.plan-transition-form .checkbox-row span {
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 14px 0 2px;
}

.checkbox-row label {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--ink);
    font-weight: 500;
}

.field:has(#dns_target_ip) {
    display: none;
}

.login-shell {
    width: min(520px, calc(100% - 24px));
    margin: 6vh auto 0;
}

.login-card { padding: 30px; }
.login-card h1 { margin-bottom: 10px; }
.login-card p { margin-top: 0; color: var(--muted); line-height: 1.8; }

.muted-box {
    padding: 18px;
    border-radius: 18px;
    background: rgba(36, 93, 76, 0.06);
    color: var(--muted);
    line-height: 1.8;
}

.admin-footer {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: flex-end;
    padding: 4px 6px 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.admin-footer a {
    color: var(--muted);
    text-decoration: none;
}

.admin-footer a:hover {
    color: var(--accent);
}

@media (max-width: 980px) {
    .metrics,
    .form-grid,
    .wallet-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .site-modal-body,
    .site-card-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .site-list-head,
    .site-summary-grid {
        grid-template-columns: 110px minmax(160px, 1fr) minmax(160px, 1fr) minmax(180px, 1.4fr) 120px 110px;
    }

    .admin-header {
        justify-content: flex-start;
    }

    .admin-nav {
        flex-basis: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .admin-shell { width: min(100% - 16px, 1320px); }
    .admin-header { padding: 16px; }
    .metrics,
    .form-grid,
    .wallet-info-grid,
    .site-modal-body,
    .site-card-actions,
    .manual-renewal-form { grid-template-columns: 1fr; }
    .payment-history-item dl { grid-template-columns: 1fr; }
    .card { padding: 18px; }
    th, td { min-width: 160px; }

    .site-list-head {
        display: none;
    }

    .site-summary-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .site-summary-item {
        display: grid;
        gap: 4px;
    }

    .site-summary-item::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 600;
    }

    .site-summary-action {
        justify-content: flex-start;
    }

    .site-modal-dialog {
        width: calc(100% - 16px);
        max-height: calc(100vh - 16px);
        margin: 8px auto;
        padding: 18px;
    }

    .site-modal-header {
        flex-direction: column;
    }

    .site-modal-header h3 {
        font-size: 21px;
    }

    .manual-renewal-submit {
        justify-content: stretch;
    }

    .manual-renewal-submit .button {
        width: 100%;
        min-width: 0;
    }
}
