:root {
    color-scheme: dark;
    --bg: #090909;
    --surface: #101010;
    --surface-2: #171717;
    --surface-3: #202020;
    --line: #292929;
    --line-strong: #3b3b3b;
    --text: #f7f7f7;
    --muted: #9a9a9a;
    --soft: #c7c7c7;
    --white: #ffffff;
    --black: #050505;
    --green: #42c77a;
    --red: #f06b6b;
    --amber: #e6b75c;
    --blue: #78a9ff;
    --radius: 7px;
    --sidebar: 244px;
    font-family: Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.icon { display: block; flex: 0 0 auto; }
.is-hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 0 0 auto; width: var(--sidebar); z-index: 30;
    display: flex; flex-direction: column; padding: 24px 14px 16px;
    background: #0d0d0d; border-left: 1px solid var(--line);
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 25px; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; background: var(--white); color: var(--black); border-radius: 7px; }
.side-brand strong, .login-brand strong { display: block; font-size: 15px; direction: ltr; text-align: right; }
.side-brand span, .login-brand span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.side-nav { display: grid; gap: 4px; }
.nav-item {
    width: 100%; min-height: 43px; border: 0; border-radius: 6px; padding: 0 12px;
    display: flex; align-items: center; gap: 11px; background: transparent; color: var(--muted); text-align: right;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.is-active { background: var(--white); color: var(--black); font-weight: 700; }
.nav-item b { margin-right: auto; min-width: 22px; height: 20px; display: grid; place-items: center; background: #2b2b2b; color: var(--soft); border-radius: 10px; font-size: 10px; }
.nav-item.is-active b { background: #dedede; color: #111; }
.side-status { margin-top: auto; padding: 14px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.side-status div { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.side-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(240,107,107,.12); }
.side-status i.online { background: var(--green); box-shadow: 0 0 0 3px rgba(66,199,122,.12); }
.side-status strong { display: block; margin-top: 8px; font-size: 12px; }
.logout-link { margin-top: 8px; }

.main-content { margin-right: var(--sidebar); min-width: 0; padding: 0 34px 50px; }
.topbar { height: 91px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.page-title h1 { margin: 0; font-size: 20px; }
.page-title p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.top-actions { margin-right: auto; display: flex; align-items: center; gap: 9px; }
.mobile-menu { display: none !important; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--soft); }
.icon-btn:hover { border-color: var(--line-strong); color: var(--white); background: var(--surface-2); }
.btn { min-height: 39px; border: 1px solid transparent; border-radius: 6px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--white); color: var(--black); }
.btn-primary:hover { background: #e6e6e6; }
.btn-secondary { background: var(--surface-3); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover, .btn-ghost:hover { background: #292929; }
.btn-ghost { color: var(--soft); background: transparent; border-color: var(--line); }
.btn-block { width: 100%; }
.text-btn { border: 0; background: transparent; color: var(--soft); padding: 6px; }
.text-btn:hover { color: var(--white); }

.view { display: none; }
.view.is-visible { display: block; animation: reveal .18s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.agent-alert { display: flex; align-items: center; gap: 12px; padding: 13px 15px; margin-bottom: 18px; background: rgba(240,107,107,.08); border: 1px solid rgba(240,107,107,.28); border-radius: var(--radius); color: var(--red); }
.agent-alert strong, .agent-alert span { display: block; }
.agent-alert span { margin-top: 3px; color: #c99898; font-size: 11px; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.metric { position: relative; min-height: 129px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.metric > span { color: var(--muted); font-size: 11px; }
.metric strong { display: block; margin-top: 10px; font-size: 28px; direction: ltr; text-align: right; }
.metric small { display: block; margin-top: 8px; color: var(--muted); }
.metric > .icon { position: absolute; left: 17px; top: 18px; color: #646464; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin: 30px 0 13px; }
.section-head.compact { margin-top: 0; align-items: center; }
.section-head h2 { margin: 0; font-size: 15px; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }

.bot-table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; min-width: 880px; }
.data-table.empty-table { min-width: 100%; }
.data-table th { height: 43px; padding: 0 15px; background: #141414; border-bottom: 1px solid var(--line); color: #818181; font-size: 10px; font-weight: 400; text-align: right; white-space: nowrap; }
.data-table td { height: 70px; padding: 10px 15px; border-bottom: 1px solid #232323; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #131313; }
.customer-cell { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.customer-cell > span { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid #3a3a3a; border-radius: 50%; background: #1d1d1d; font-weight: 700; }
.customer-cell strong, .customer-cell small, .mono-stack strong, .mono-stack small, .expiry strong, .expiry small, .live-state { display: block; }
.customer-cell small, .mono-stack small, .expiry small, .live-state { color: var(--muted); margin-top: 5px; font-size: 10px; }
.mono-stack { min-width: 110px; }
.mono-stack strong, .mono-stack small, .domain-link { font-family: Consolas, monospace; }
.status { width: max-content; display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 4px; font-size: 10px; white-space: nowrap; }
.status i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-good { color: var(--green); background: rgba(66,199,122,.09); }
.status-wait { color: var(--amber); background: rgba(230,183,92,.09); }
.status-bad { color: var(--red); background: rgba(240,107,107,.09); }
.status-muted { color: #aaa; background: #202020; }
.text-danger { color: var(--red) !important; }
.domain-link { display: inline-flex; align-items: center; gap: 6px; color: #cfcfcf; font-size: 11px; }
.domain-link:hover { color: var(--white); }
.empty-state { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--soft); }
.empty-state span { font-size: 11px; }
.quiet-empty { padding: 28px; color: var(--muted); text-align: center; font-size: 11px; }

.dashboard-split { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(280px,.8fr); gap: 14px; margin-top: 26px; }
.activity-panel, .expiry-panel { padding: 17px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); }
.timeline { display: grid; }
.timeline-item { min-height: 52px; display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 11px; border-top: 1px solid #242424; }
.timeline-item > i { width: 7px; height: 7px; border-radius: 50%; background: #6a6a6a; }
.timeline-item > i.op-success { background: var(--green); }
.timeline-item > i.op-failed { background: var(--red); }
.timeline-item > i.op-working, .timeline-item > i.op-queued { background: var(--amber); }
.timeline-item strong, .timeline-item span { display: block; }
.timeline-item span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.timeline-item time { color: #707070; font-size: 10px; direction: ltr; }
.expiry-list { display: grid; }
.expiry-list button { width: 100%; min-height: 52px; padding: 8px 0; display: flex; align-items: center; justify-content: space-between; border: 0; border-top: 1px solid #242424; background: transparent; color: var(--text); text-align: right; }
.expiry-list span, .expiry-list small { display: block; }
.expiry-list small { margin-top: 4px; color: var(--muted); font: 10px Consolas, monospace; }
.expiry-list strong { color: var(--amber); font-size: 11px; }

.toolbar { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.toolbar .btn { margin-right: auto; }
.search-box { width: min(390px,45vw); height: 40px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); }
.search-box:focus-within { border-color: #555; color: var(--text); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.select-compact { height: 40px; min-width: 145px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--soft); }
.operation-list { border-top: 1px solid var(--line); }
.operation-list article { min-height: 76px; display: grid; grid-template-columns: 40px minmax(180px,1fr) auto 125px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.operation-icon { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }
.operation-list strong { font-size: 12px; }
.operation-list p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.operation-list time { color: var(--muted); direction: ltr; text-align: left; font-size: 10px; }

.backup-picker { display: grid; grid-template-columns: minmax(220px,380px) auto auto; align-items: end; gap: 10px; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.backup-list { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.backup-item { min-height: 64px; padding: 10px 15px; display: grid; grid-template-columns: 1fr 100px 150px auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.backup-item:last-child { border: 0; }
.backup-item strong { direction: ltr; text-align: right; font: 11px Consolas, monospace; overflow-wrap: anywhere; }
.backup-item span, .backup-item time { color: var(--muted); font-size: 10px; }

.settings-layout { display: grid; grid-template-columns: minmax(300px,.8fr) minmax(300px,1.2fr); gap: 30px; }
.settings-layout > section { padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.settings-form { max-width: 440px; display: grid; gap: 14px; }
.settings-form .btn { width: max-content; }
.system-list { border-top: 1px solid var(--line); }
.system-list > div { min-height: 55px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.system-list > div > span { display: flex; align-items: center; gap: 9px; }
.audit-section { grid-column: 1/-1; }
.audit-list { border-top: 1px solid var(--line); }
.audit-list > div { min-height: 45px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.audit-list time { color: var(--muted); font-size: 10px; direction: ltr; }

.field { display: grid; gap: 7px; }
.field > span { color: var(--soft); font-size: 11px; }
.field > small { color: var(--muted); font-size: 9px; line-height: 1.7; }
.field input, .field select, .field textarea { width: 100%; min-height: 41px; border: 1px solid #343434; border-radius: 6px; outline: 0; background: #121212; color: var(--text); padding: 9px 11px; }
.field textarea { resize: vertical; line-height: 1.8; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #747474; }
.field input::placeholder, .field textarea::placeholder { color: #5f5f5f; }
.password-input { display: grid; grid-template-columns: 1fr 40px; }
.password-input input { border-radius: 0 6px 6px 0; }
.password-input button { border: 1px solid #343434; border-right: 0; border-radius: 6px 0 0 6px; background: #1c1c1c; color: var(--muted); display: grid; place-items: center; }

.modal, .drawer { position: fixed; inset: 0; z-index: 100; display: none; }
.modal.is-open, .drawer.is-open { display: block; }
.modal-backdrop, .drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.78); }
.modal-panel { position: relative; width: min(760px,calc(100% - 30px)); max-height: calc(100vh - 40px); margin: 20px auto; overflow: auto; background: #101010; border: 1px solid #333; border-radius: 8px; box-shadow: 0 25px 70px rgba(0,0,0,.55); }
.modal-panel > header, .drawer-panel > header { min-height: 77px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-panel > header span, .drawer-panel > header span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.modal-panel > header h2, .drawer-panel > header h2 { margin: 0; font-size: 17px; }
.form-section { padding: 20px; border-bottom: 1px solid var(--line); }
.form-section h3 { margin: 0 0 17px; display: flex; align-items: center; gap: 9px; font-size: 12px; }
.form-section h3 b { width: 23px; height: 23px; display: grid; place-items: center; background: var(--white); color: var(--black); border-radius: 50%; font-size: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.field-wide { grid-column: 1/-1; }
.modal-panel form > footer { padding: 15px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.log-modal { width: min(900px,calc(100% - 30px)); }
.log-modal pre { min-height: 430px; max-height: 65vh; margin: 0; padding: 18px; overflow: auto; background: #080808; color: #cfcfcf; font: 11px/1.8 Consolas, monospace; direction: ltr; text-align: left; white-space: pre-wrap; }

.drawer-panel { position: absolute; inset: 0 0 0 auto; width: min(430px,100%); overflow-y: auto; background: #101010; border-left: 1px solid #333; box-shadow: -20px 0 60px rgba(0,0,0,.5); }
.drawer-status { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.drawer-status div { padding: 16px 20px; }
.drawer-status div + div { border-right: 1px solid var(--line); }
.drawer-status span, .drawer-status strong { display: block; }
.drawer-status span { color: var(--muted); font-size: 10px; }
.drawer-status strong { margin-top: 7px; font-size: 12px; }
.detail-list { margin: 0; padding: 8px 20px; }
.detail-list div { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid #242424; }
.detail-list dt { color: var(--muted); font-size: 10px; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; text-align: left; font-size: 11px; }
.action-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; padding: 18px 20px; }
.action-grid button { min-height: 69px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; background: #151515; color: var(--soft); }
.action-grid button:hover { border-color: #555; color: var(--white); background: #1b1b1b; }
.action-grid span { font-size: 9px; }
.extend-form { margin: 0 20px; padding: 17px; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.drawer-notes { margin: 18px 20px; }
.drawer-notes span { color: var(--muted); font-size: 10px; }
.drawer-notes p { margin: 7px 0 0; line-height: 1.9; color: var(--soft); white-space: pre-wrap; }
.danger-action { width: calc(100% - 40px); min-height: 42px; margin: 4px 20px 24px; border: 1px solid rgba(240,107,107,.35); border-radius: 6px; background: rgba(240,107,107,.06); color: var(--red); display: flex; align-items: center; justify-content: center; gap: 8px; }
.danger-action:hover { background: rgba(240,107,107,.12); }

.toast-stack { position: fixed; left: 18px; bottom: 18px; z-index: 200; width: min(360px,calc(100% - 36px)); display: grid; gap: 8px; }
.toast { padding: 13px 14px; display: flex; gap: 9px; align-items: flex-start; border: 1px solid #3b3b3b; border-radius: 6px; background: #181818; box-shadow: 0 10px 35px rgba(0,0,0,.45); color: var(--soft); animation: toastIn .2s ease-out; }
.toast.toast-error { border-color: rgba(240,107,107,.4); color: #ffc3c3; }
.toast strong { display: block; color: var(--white); font-size: 11px; }
.toast span { display: block; margin-top: 4px; font-size: 10px; line-height: 1.7; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.login-page { display: grid; place-items: center; padding: 24px; background: #080808; }
.login-shell { width: min(420px,100%); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 11px; margin-bottom: 22px; }
.login-panel { padding: 29px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 25px 80px rgba(0,0,0,.5); }
.login-heading { margin-bottom: 22px; }
.secure-badge { width: max-content; display: flex !important; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid #333; border-radius: 4px; color: var(--soft) !important; }
.login-heading h1 { margin: 16px 0 0; font-size: 22px; }
.login-heading p { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.login-form { display: grid; gap: 15px; }
.login-foot { margin: 15px 0 0; text-align: center; color: #626262; font-size: 9px; }
.notice { display: flex; align-items: center; gap: 8px; padding: 10px; margin-bottom: 14px; border-radius: 5px; font-size: 10px; }
.notice-error { color: #ffc0c0; background: rgba(240,107,107,.09); border: 1px solid rgba(240,107,107,.25); }

@media (max-width: 1050px) {
    .metrics-grid { grid-template-columns: repeat(2,1fr); }
    .dashboard-split { grid-template-columns: 1fr; }
    .settings-layout { grid-template-columns: 1fr; }
    .audit-section { grid-column: auto; }
}

@media (max-width: 760px) {
    :root { --sidebar: 250px; }
    .sidebar { transform: translateX(105%); transition: transform .2s ease; box-shadow: -20px 0 50px rgba(0,0,0,.6); }
    .sidebar.is-open { transform: none; }
    .main-content { margin-right: 0; padding: 0 15px 35px; }
    .topbar { height: 74px; margin-bottom: 20px; }
    .mobile-menu { display: inline-grid !important; }
    .page-title p { display: none; }
    .top-actions { gap: 6px; }
    .top-actions .btn { font-size: 0; width: 39px; padding: 0; }
    .top-actions .btn .icon { width: 18px; height: 18px; }
    .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
    .metric { min-height: 112px; padding: 14px; }
    .metric strong { font-size: 24px; }
    .metric > .icon { left: 13px; top: 14px; }
    .toolbar { flex-wrap: wrap; }
    .search-box { width: 100%; }
    .toolbar .btn { margin-right: 0; margin-left: auto; }
    .operation-list article { grid-template-columns: 36px 1fr auto; padding: 11px 0; }
    .operation-list article time { display: none; }
    .backup-picker { grid-template-columns: 1fr 1fr; }
    .backup-picker .field { grid-column: 1/-1; }
    .backup-item { grid-template-columns: 1fr auto; }
    .backup-item time { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
}

@media (max-width: 430px) {
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .metric { min-height: 105px; }
    .metric small { max-width: 90px; }
    .modal-panel { width: 100%; max-height: 100vh; min-height: 100vh; margin: 0; border: 0; border-radius: 0; }
    .form-section { padding: 17px 15px; }
    .modal-panel form > footer { position: sticky; bottom: 0; background: #101010; padding: 12px 15px; }
    .action-grid { grid-template-columns: repeat(2,1fr); }
    .extend-form { grid-template-columns: 1fr; }
}
