@font-face {
    font-family: "CharismaTF";
    src: url("../CharismaTF-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #050505;
    --sidebar: #181818;
    --surface: #151515;
    --surface-2: #202020;
    --surface-3: #2a2a2a;
    --border: #343434;
    --text: #f7f7f7;
    --muted: #b8b8b8;
    --soft: #888;
    --accent: #e8e8e8;
    --success: #44d07b;
    --danger: #ff5d6c;
    --warning: #f3bd4e;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

body.light {
    --bg: #f2f2f2;
    --sidebar: #ffffff;
    --surface: #ffffff;
    --surface-2: #eeeeee;
    --surface-3: #e1e1e1;
    --border: #d7d7d7;
    --text: #121212;
    --muted: #575757;
    --soft: #777;
    --accent: #161616;
    --shadow: 0 20px 55px rgba(0, 0, 0, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: "CharismaTF", Tahoma, Arial, sans-serif;
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
}

.auth-body {
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-shell {
    width: min(100%, 420px);
}

.auth-panel,
.panel,
.topbar,
.metric-card,
.status-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015)), var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.auth-panel {
    padding: 34px;
}

.brand-mark {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 50%;
    background: #0d0d0d;
}

.brand-mark.small {
    width: 34px;
    height: 34px;
}

.auth-panel h1,
.topbar-title span,
.panel h2 {
    margin: 0;
    font-weight: 800;
}

.auth-panel p,
.eyebrow,
.sidebar small,
.metric-card span,
.metric-card small {
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

label span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

input,
select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    padding: 0 14px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: left 18px center, left 12px center;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-left: 42px;
}

input:focus,
select:focus {
    border-color: #777;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.primary-btn,
.secondary-btn,
.icon-btn,
.row-action,
.quick-create,
.nav-button,
.status-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-btn {
    min-height: 46px;
    padding: 0 18px;
    color: #111;
    background: #f0f0f0;
    font-weight: 800;
}

.secondary-btn {
    min-height: 46px;
    padding: 0 18px;
    color: var(--text);
    background: var(--surface-2);
}

.primary-btn:hover,
.secondary-btn:hover,
.icon-btn:hover,
.row-action:hover,
.quick-create:hover,
.nav-button:hover,
.status-toggle:hover {
    transform: translateY(-1px);
    border-color: #666;
}

.app-shell {
    direction: rtl;
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar,
.workspace {
    direction: rtl;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 20px;
    padding: 24px 18px;
    background: var(--sidebar);
    border-left: 1px solid var(--border);
    grid-column: 1;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand strong {
    display: block;
    font-size: 1.1rem;
}

.quick-create {
    min-height: 46px;
    padding: 0 14px;
    color: #111;
    background: #e6e6e6;
    justify-content: flex-start;
    width: 100%;
}

.side-nav {
    display: grid;
    align-content: start;
    gap: 10px;
}

.side-nav a,
.nav-button {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 12px;
    color: var(--text);
    text-decoration: none;
    border-radius: 10px;
    background: transparent;
    border: 0;
    justify-content: flex-start;
    width: 100%;
}

.side-nav a.active,
.side-nav a:hover,
.nav-button:hover {
    background: var(--surface-2);
}

.workspace {
    display: grid;
    align-content: start;
    gap: 24px;
    min-width: 0;
    padding: 18px 28px 34px;
    grid-column: 2;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 24px;
    border-radius: 0;
    border-top: 0;
    border-right: 0;
    border-left: 0;
    background: #0b0b0b;
}

body.light .topbar {
    background: #fff;
}

.topbar-title,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title svg {
    padding-left: 14px;
    border-left: 1px solid var(--border);
}

.icon-btn,
.row-action {
    width: 42px;
    height: 42px;
    color: var(--text);
    background: var(--surface);
}

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

.metric-card {
    height: 148px;
    padding: 26px 28px;
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
    display: grid;
    align-content: space-between;
    overflow: hidden;
}

.metric-card span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.metric-card strong {
    display: block;
    margin: 10px 0 18px;
    font-size: 2.35rem;
    line-height: 1;
}

.panel {
    padding: 24px 28px;
}

.compact-panel {
    padding-bottom: 28px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.eyebrow {
    display: block;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.search-box {
    position: relative;
    width: min(100%, 360px);
}

.search-box svg {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    color: var(--muted);
}

.search-box input {
    padding-right: 44px;
}

.notice {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}

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

.records-box {
    position: relative;
    max-height: 520px;
    overflow: auto;
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #090909;
}

body.light .records-box {
    background: #fafafa;
}

.records-box::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.records-box::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 99px;
}

.records-table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
}

.records-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-3);
}

.records-table th,
.records-table td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.records-table th {
    color: var(--text);
    font-weight: 800;
}

.records-table tr {
    transition: background 140ms ease;
}

.records-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.035);
}

.type-pill {
    display: inline-flex;
    min-width: 52px;
    min-height: 30px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    background: var(--surface-2);
    font-weight: 800;
}

.editable-cell {
    display: inline-flex;
    max-width: 430px;
    min-height: 34px;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: text;
    direction: ltr;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editable-cell:hover {
    border-color: var(--border);
    background: var(--surface-2);
}

.inline-input {
    width: min(430px, 100%);
    min-height: 34px;
    direction: ltr;
    text-align: left;
}

.status-toggle {
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--text);
    background: var(--surface-2);
}

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

.status-toggle.dns {
    color: var(--muted);
}

.dialog {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 22px;
}

.dialog[hidden] {
    display: none;
}

.dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(10px);
}

.dialog-card {
    position: relative;
    width: min(100%, 620px);
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)), var(--surface);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.58);
    padding: 22px;
    animation: rise 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.dialog-header {
    display: grid;
    grid-template-columns: 48px 1fr 42px;
    align-items: center;
    gap: 14px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.dialog-header h3 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
}

.dialog-icon {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

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

.dialog-grid label:nth-child(3) {
    grid-column: 1 / -1;
}

.dialog-switch {
    display: flex;
    align-items: end;
}

.dialog-switch input {
    position: absolute;
    opacity: 0;
}

.dialog-switch span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--muted);
}

.dialog-switch input:checked + span {
    color: var(--success);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
}

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

.row-action.danger {
    color: var(--danger);
}

.empty-state,
.status-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--muted);
    min-height: 130px;
}

.motion-rise {
    animation: rise 440ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 250px minmax(0, 1fr);
    }

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

}

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

    .sidebar {
        position: static;
        height: auto;
        border-left: 0;
        border-bottom: 1px solid var(--border);
        grid-column: auto;
    }

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

    .workspace {
        padding: 14px;
        grid-column: auto;
    }

    .topbar,
    .panel-heading {
        display: grid;
        grid-template-columns: 1fr;
    }

    .metrics-grid,
    .dialog-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        height: 138px;
    }

    .dialog-grid label:nth-child(3) {
        grid-column: auto;
    }

    .records-box {
        max-height: 60vh;
    }

    .search-box {
        width: 100%;
    }
}

.app-body {
    overflow-x: hidden;
}

.record-text {
    display: inline-block;
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-text.ltr {
    direction: ltr;
    text-align: left;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .workspace {
        padding: 14px 18px 28px;
    }

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

    .metric-card {
        height: 136px;
        padding: 20px;
    }

    .metric-card strong {
        font-size: 2rem;
    }

    .records-table {
        min-width: 760px;
    }
}

@media (max-width: 820px) {
    body {
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 180px), var(--bg);
    }

    .app-shell {
        display: block;
        min-height: 100vh;
        padding-bottom: 86px;
    }

    .sidebar {
        position: static;
        height: auto;
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 12px;
        padding: 14px;
        background: rgba(18, 18, 18, 0.94);
        border-left: 0;
        border-bottom: 1px solid var(--border);
        box-shadow: none;
    }

    body.light .sidebar {
        background: rgba(255, 255, 255, 0.94);
    }

    .sidebar-brand {
        min-width: 0;
    }

    .sidebar-brand strong {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1rem;
    }

    .sidebar small {
        display: none;
    }

    .quick-create {
        width: auto;
        min-width: 46px;
        min-height: 46px;
        padding: 0 13px;
        border-radius: 14px;
        justify-content: center;
        font-size: 0;
    }

    .quick-create svg {
        width: 22px;
        height: 22px;
    }

    .side-nav {
        position: fixed;
        right: 12px;
        left: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
        z-index: 50;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
        padding: 8px;
        border: 1px solid var(--border);
        border-radius: 20px;
        background: rgba(20, 20, 20, 0.92);
        backdrop-filter: blur(18px);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    }

    body.light .side-nav {
        background: rgba(255, 255, 255, 0.92);
    }

    .side-nav a,
    .nav-button {
        display: grid;
        min-height: 54px;
        justify-items: center;
        align-content: center;
        gap: 3px;
        padding: 6px 4px;
        border-radius: 14px;
        font-size: 0.72rem;
        line-height: 1.2;
        text-align: center;
    }

    .side-nav svg,
    .nav-button svg {
        width: 20px;
        height: 20px;
    }

    .workspace {
        display: block;
        padding: 12px;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 30;
        min-height: 58px;
        margin: 0 -12px 14px;
        padding: 0 14px;
        border-radius: 0 0 18px 18px;
        border-right: 0;
        border-left: 0;
    }

    .topbar-title {
        gap: 10px;
        min-width: 0;
    }

    .topbar-title span {
        max-width: 170px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.98rem;
    }

    .topbar-title svg {
        padding-left: 10px;
    }

    .topbar-actions {
        gap: 8px;
    }

    .icon-btn,
    .row-action {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 14px;
    }

    .metric-card {
        height: 118px;
        min-width: 0;
        padding: 14px;
        border-radius: 16px;
    }

    .metric-card span {
        gap: 6px;
        font-size: 0.78rem;
        white-space: nowrap;
    }

    .metric-card span svg {
        width: 17px;
        height: 17px;
        flex: 0 0 auto;
    }

    .metric-card strong {
        margin: 6px 0;
        font-size: 1.85rem;
    }

    .metric-card small {
        font-size: 0.72rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .panel {
        padding: 14px;
        border-radius: 18px;
    }

    .panel-heading {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .panel h2 {
        font-size: 1.28rem;
    }

    .search-box {
        width: 100%;
    }

    .search-box input {
        min-height: 44px;
        border-radius: 14px;
    }

    .records-box {
        max-height: none;
        overflow: visible;
        border: 0;
        background: transparent;
        margin-top: 14px;
    }

    .records-table,
    .records-table thead,
    .records-table tbody,
    .records-table tr,
    .records-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .records-table {
        border-collapse: separate;
        border-spacing: 0;
    }

    .records-table thead {
        display: none;
    }

    .records-table tbody {
        display: grid;
        gap: 12px;
    }

    .records-table tr {
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 16px;
        background: #090909;
        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
    }

    body.light .records-table tr {
        background: #fff;
    }

    .records-table td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        align-items: center;
        gap: 10px;
        min-height: 42px;
        padding: 8px 0;
        border-bottom: 1px solid var(--border);
    }

    .records-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.78rem;
    }

    .records-table td:last-child {
        border-bottom: 0;
    }

    .type-pill {
        min-width: 44px;
        min-height: 28px;
        justify-self: start;
    }

    .record-text {
        max-width: 100%;
        min-width: 0;
        justify-self: start;
    }

    .status-toggle {
        width: 40px;
        height: 40px;
        justify-self: start;
        border-radius: 12px;
    }

    .row-actions {
        justify-content: flex-start;
    }

    .dialog {
        align-items: end;
        padding: 0;
    }

    .dialog-card {
        width: 100%;
        max-height: min(88vh, 720px);
        overflow: auto;
        border-radius: 24px 24px 0 0;
        border-right: 0;
        border-left: 0;
        border-bottom: 0;
        padding: 16px;
    }

    .dialog-header {
        grid-template-columns: 42px 1fr 40px;
        gap: 10px;
        padding-bottom: 14px;
    }

    .dialog-icon {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    .dialog-header h3 {
        font-size: 1.22rem;
    }

    .dialog-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-top: 16px;
    }

    .dialog-grid label:nth-child(3) {
        grid-column: auto;
    }

    .dialog-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-top: 18px;
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }

    .primary-btn,
    .secondary-btn {
        width: 100%;
        min-height: 48px;
        border-radius: 14px;
        padding: 0 12px;
    }
}

@media (max-width: 430px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        height: 102px;
        grid-template-columns: 1fr auto;
        align-items: center;
        align-content: center;
        gap: 4px 10px;
    }

    .metric-card span,
    .metric-card small {
        grid-column: 1;
    }

    .metric-card strong {
        grid-column: 2;
        grid-row: 1 / span 2;
        margin: 0;
        font-size: 2rem;
    }

    .records-table td {
        grid-template-columns: 78px minmax(0, 1fr);
    }

    .side-nav a,
    .nav-button {
        font-size: 0.66rem;
    }
}

@media (max-width: 360px) {
    .topbar-title span {
        max-width: 128px;
    }

    .side-nav {
        right: 8px;
        left: 8px;
        gap: 4px;
    }

    .side-nav a,
    .nav-button {
        min-height: 50px;
        font-size: 0;
    }

    .records-table td {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
