:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --line: #d9e2ec;
    --text: #1f2937;
    --muted: #64748b;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #b91c1c;
    --warning: #b45309;
    --success: #047857;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    padding: 10px 14px;
}

.button-link {
    align-items: center;
    background: var(--primary);
    border-radius: 6px;
    color: #ffffff;
    display: inline-flex;
    padding: 10px 14px;
    text-decoration: none;
}

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

.button-link.secondary {
    background: #475569;
}

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

button.secondary,
button[data-reset-form] {
    background: #475569;
}

button.danger {
    background: var(--danger);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.link-button {
    background: transparent;
    color: var(--primary);
    padding: 0;
}

.link-button:hover {
    background: transparent;
    color: var(--primary-dark);
}

.admin-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #102a43;
    color: #ffffff;
    padding: 24px 18px;
}

.brand {
    color: #ffffff;
    display: block;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    text-decoration: none;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a {
    border-radius: 6px;
    color: #dbeafe;
    padding: 10px 12px;
    text-decoration: none;
}

.nav a.active,
.nav a:hover {
    background: #1f4e79;
    color: #ffffff;
}

.main {
    min-width: 0;
    padding: 24px;
}

.topbar {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 20px;
}

.topbar h1 {
    font-size: 28px;
    line-height: 1.2;
    margin: 0 0 4px;
}

.topbar p {
    color: var(--muted);
    margin: 0;
}

.account-pill,
.notice,
.panel,
.toolbar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.account-pill {
    align-items: center;
    color: var(--muted);
    display: flex;
    gap: 10px;
    padding: 8px 12px;
    white-space: nowrap;
}

.notice {
    margin-bottom: 18px;
    padding: 12px 14px;
}

.notice.error {
    border-color: #fecaca;
    color: var(--danger);
}

.toolbar {
    margin-bottom: 18px;
    padding: 14px;
}

.inline-form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inline-form input,
.inline-form select {
    min-width: 180px;
}

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

.panel {
    padding: 18px;
}

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

.panel h2 {
    font-size: 18px;
    margin: 0 0 14px;
}

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

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

.service-form .full-field,
.service-form .actions {
    grid-column: 1 / -1;
}

.provider-context {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
}

.provider-context select {
    max-width: 420px;
}

.duration-field,
.price-periods {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 0;
    padding: 14px;
}

.duration-field legend {
    color: var(--text);
    font-weight: 600;
    padding: 0 6px;
}

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

.duration-field > small,
.price-periods p {
    color: var(--muted);
}

.duration-field > small {
    display: block;
    margin-top: 8px;
}

.section-heading {
    align-items: start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.section-heading h3,
.section-heading p {
    margin: 0;
}

.section-heading p {
    margin-top: 5px;
}

.price-period-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.price-period-row {
    align-items: end;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(160px, 1.4fr) repeat(2, minmax(135px, 1fr)) minmax(165px, 1fr) auto;
    padding: 12px;
}

.price-period-row button {
    white-space: nowrap;
}

.price-period-empty {
    margin-bottom: 0;
}

[data-vietnamese-date] {
    background: #fff;
    cursor: pointer;
}

.vietnamese-date-picker {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.2);
    padding: 12px;
    position: absolute;
    z-index: 1000;
}

.calendar-header,
.calendar-footer {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.calendar-header strong {
    color: var(--text);
    text-align: center;
}

.calendar-header button,
.calendar-footer button,
.calendar-day {
    min-height: 36px;
    padding: 6px;
}

.calendar-weekdays,
.calendar-days {
    display: grid;
    gap: 4px;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-weekdays {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    margin: 10px 0 6px;
    text-align: center;
}

.calendar-weekdays span {
    padding: 4px 0;
}

.calendar-day {
    background: transparent;
    color: var(--text);
    width: 100%;
}

.calendar-day:hover,
.calendar-day.today {
    background: #e0f2fe;
    color: #075985;
}

.calendar-day.selected {
    background: var(--primary);
    color: #fff;
}

.calendar-day.empty {
    display: block;
}

.calendar-footer {
    border-top: 1px solid var(--line);
    margin-top: 10px;
    padding-top: 10px;
}

.calendar-footer button {
    background: transparent;
    color: var(--primary);
}

label {
    color: var(--muted);
    display: grid;
    gap: 6px;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    min-width: 0;
    padding: 9px 10px;
    width: 100%;
}

select[multiple] {
    min-height: 150px;
}

textarea {
    resize: vertical;
}

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

.media-field {
    border: 1px dashed var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    padding: 12px;
}

.media-json {
    min-height: 74px;
}

.media-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.media-status {
    color: var(--muted);
    margin: 0;
    min-height: 20px;
}

.media-status.uploading {
    color: var(--warning);
}

.media-status.success {
    color: var(--success);
}

.media-status.error {
    color: var(--danger);
}

.media-preview-item {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    width: 132px;
}

.media-preview-item img {
    aspect-ratio: 4 / 3;
    display: block;
    object-fit: cover;
    width: 100%;
}

.media-preview-item button {
    border-radius: 0;
    font-size: 12px;
    padding: 7px 8px;
    width: 100%;
}

.service-thumbnail {
    border-radius: 6px;
    height: 58px;
    object-fit: cover;
    width: 78px;
}

.muted,
.empty-state,
label small {
    color: var(--muted);
}

.empty-state {
    margin: 16px 0 0;
    text-align: center;
}

.service-result {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    padding: 16px;
}

.service-result h3 {
    color: var(--success);
    margin: 0 0 14px;
}

.service-result-grid {
    align-items: start;
    display: grid;
    gap: 16px;
    grid-template-columns: 160px 1fr;
}

.service-result-grid > img {
    border-radius: 8px;
    max-height: 130px;
    object-fit: cover;
    width: 100%;
}

.service-result dl {
    display: grid;
    gap: 8px;
    margin: 0;
}

.service-result dl div {
    display: grid;
    gap: 8px;
    grid-template-columns: 130px 1fr;
}

.service-result dt {
    color: var(--muted);
}

.service-result dd {
    margin: 0;
}

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

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

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

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status {
    border-radius: 999px;
    display: inline-flex;
    font-size: 13px;
    padding: 4px 8px;
}

.status.active,
.status.published {
    background: #dcfce7;
    color: var(--success);
}

.status.inactive,
.status.hidden,
.status.draft {
    background: #f1f5f9;
    color: #475569;
}

.status.pending {
    background: #fef3c7;
    color: var(--warning);
}

.status.rejected {
    background: #fee2e2;
    color: var(--danger);
}

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

.metric {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.metric span {
    color: var(--muted);
    display: block;
    margin-bottom: 6px;
}

.metric strong {
    font-size: 18px;
}

.toast {
    bottom: 20px;
    box-shadow: 0 12px 32px rgb(15 23 42 / 18%);
    display: none;
    left: 50%;
    max-width: min(520px, calc(100vw - 32px));
    padding: 12px 16px;
    position: fixed;
    transform: translateX(-50%);
    z-index: 20;
}

.toast.show {
    border-radius: 8px;
    display: block;
}

.toast.success {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: var(--success);
}

.toast.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
}

.auth-body {
    align-items: center;
    background: #eef6f4;
    display: flex;
    min-height: 100vh;
    padding: 24px;
}

.auth-shell {
    margin: 0 auto;
    width: min(440px, 100%);
}

.auth-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgb(15 23 42 / 10%);
    padding: 28px;
}

.auth-brand {
    color: var(--primary);
    display: inline-flex;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 22px;
    text-decoration: none;
}

.auth-header h1 {
    font-size: 26px;
    margin: 0 0 8px;
}

.auth-header p {
    color: var(--muted);
    line-height: 1.5;
    margin: 0 0 20px;
}

.auth-form button[type="submit"] {
    width: 100%;
}

.checkbox-line {
    align-items: center;
    color: var(--text);
    display: flex;
    gap: 10px;
}

.checkbox-line input {
    width: auto;
}

.form-message {
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
    min-height: 22px;
}

.form-message.success {
    color: var(--success);
}

.form-message.error {
    color: var(--danger);
}

.form-hint {
    color: var(--muted);
    line-height: 1.5;
    margin: -4px 0 12px;
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    margin-top: 18px;
}

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

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

.modal-dialog {
    width: min(760px, calc(100% - 32px));
    max-height: min(86vh, 860px);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    background: #ffffff;
    overflow: auto;
    box-shadow: var(--shadow);
}

.modal-dialog::backdrop {
    background: rgba(15, 23, 42, 0.42);
}

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

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

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

.detail-list div {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.detail-list dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
}

@media (max-width: 980px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .workspace,
    .service-form,
    .service-result-grid,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .duration-inputs,
    .price-period-row {
        grid-template-columns: 1fr;
    }

    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }
}
