/* Server inventory — Apple-inspired design tokens (see .cursor/rules/apple-inspired-design-system.mdc) */

/* Prevent layout width jumping when a scrollbar appears (e.g. on hover / overflow) — stabilizes 100vw-based --layout-max */
html {
    scrollbar-gutter: stable;
}

/* ----- Light appearance (default) ----- */
:root {
    --sk-focus-color: #0071e3;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    color-scheme: light;
    --page-bg: #f5f5f7;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-muted: #fafafc;
    --surface-row-alt: #f5f5f7;
    --text-primary: #1d1d1f;
    /* Data row hover: subtle neutral tint from text on surface */
    --table-row-hover: color-mix(in srgb, var(--text-primary) 5%, var(--surface));
    --text-secondary: rgba(0, 0, 0, 0.8);
    --text-tertiary: rgba(0, 0, 0, 0.48);
    --link: #0066cc;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --border-hairline: rgba(0, 0, 0, 0.06);
    --border-field: rgba(0, 0, 0, 0.12);
    --filter-border: rgba(0, 0, 0, 0.04);
    --nav-glass: rgba(0, 0, 0, 0.8);
    --shadow-card: 0 3px 30px rgba(0, 0, 0, 0.12);
    --modal-scrim: rgba(0, 0, 0, 0.45);
    --status-danger: #b00020;
    --status-danger-bg: rgba(176, 0, 32, 0.08);
    --status-warn: #8a5a00;
    --status-warn-bg: rgba(138, 90, 0, 0.1);
    --status-success-fg: #0071e3;
    --toggle-off: #d2d2d7;
    --chip-bg: #ffffff;
    --chip-border: rgba(0, 0, 0, 0.08);
    /* Content width: Apple ~980px baseline; scales up on large displays with side margins */
    --layout-max: 980px;
}

@media (min-width: 1200px) {
    :root {
        --layout-max: min(1120px, calc(100vw - 48px));
    }
}

@media (min-width: 1440px) {
    :root {
        --layout-max: min(1240px, calc(100vw - 64px));
    }
}

@media (min-width: 1680px) {
    :root {
        --layout-max: min(1380px, calc(100vw - 80px));
    }
}

@media (min-width: 1920px) {
    :root {
        --layout-max: min(1540px, calc(100vw - 96px));
    }
}

/* Single ultra-wide rule: avoids a 2560px “cliff” where scrollbar shrink drops min-width below 2560 and reverts to 1680 */
@media (min-width: 2200px) {
    :root {
        --layout-max: min(1780px, calc(100vw - 120px));
    }
}

/* ----- Dark appearance ----- */
html[data-theme="dark"] {
    color-scheme: dark;
    --page-bg: #000000;
    --surface: #272729;
    --surface-raised: #2a2a2d;
    --surface-muted: #1d1d1f;
    /* Zebra rows: darker than --surface (#272729); prior #262628 was ~1 RGB step — stripes disappeared */
    --surface-row-alt: #202023;
    --text-primary: #ffffff;
    --table-row-hover: color-mix(in srgb, var(--text-primary) 9%, var(--surface));
    --text-secondary: rgba(255, 255, 255, 0.85);
    --text-tertiary: rgba(255, 255, 255, 0.48);
    --link: #2997ff;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --border-hairline: rgba(255, 255, 255, 0.1);
    --border-field: rgba(255, 255, 255, 0.18);
    --filter-border: rgba(255, 255, 255, 0.08);
    --nav-glass: rgba(0, 0, 0, 0.72);
    --shadow-card: 0 3px 30px rgba(0, 0, 0, 0.35);
    --modal-scrim: rgba(0, 0, 0, 0.65);
    --status-danger: #ff6b6b;
    --status-danger-bg: rgba(255, 107, 107, 0.12);
    --status-warn: #ffcc00;
    --status-warn-bg: rgba(255, 204, 0, 0.12);
    --status-success-fg: #2997ff;
    --toggle-off: #3a3a3c;
    --chip-bg: #2a2a2d;
    --chip-border: rgba(255, 255, 255, 0.12);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-text);
    font-size: 17px;
    font-weight: 400;
    line-height: 1.47;
    letter-spacing: -0.022em;
    background-color: var(--page-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ----- Top navigation (glass) ----- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 48px;
    display: flex;
    align-items: center;
    background: var(--nav-glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-topbar-inner {
    width: 100%;
    max-width: var(--layout-max);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.app-brand {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.022em;
    color: #ffffff;
    text-decoration: none;
    white-space: nowrap;
}

.app-brand:hover {
    color: rgba(255, 255, 255, 0.85);
}

.app-brand:focus-visible {
    outline: 2px solid var(--sk-focus-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Theme segment: Light / Dark */
.theme-segment {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border-radius: 980px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    gap: 2px;
}

.theme-segment__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: 980px;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    font-family: var(--font-text);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.33;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.theme-segment__btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.9;
}

.theme-segment__btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.theme-segment__btn:focus-visible {
    outline: 2px solid var(--sk-focus-color);
    outline-offset: 2px;
}

.theme-segment__btn[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

/* ----- Main layout ----- */
.app-main {
    width: 100%;
    max-width: var(--layout-max);
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.ds-page-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0 0 8px;
    color: var(--text-primary);
}

.ds-page-lead {
    margin: 0;
    font-size: 14px;
    line-height: 1.43;
    letter-spacing: -0.016em;
    color: var(--text-secondary);
}

/* List/dashboard header: title + stats left, primary actions right; tight vertical rhythm */
.ds-page-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 16px;
}

.ds-page-head__intro {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.ds-page-head__intro .ds-page-title {
    margin-bottom: 0;
}

.ds-page-head__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.ds-page-head__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.ds-page-head__toolbar form {
    display: inline;
}

@media (min-width: 768px) {
    .ds-page-head {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 16px 24px;
    }

    .ds-page-head__toolbar {
        flex-shrink: 0;
        justify-content: flex-end;
    }
}

.ds-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.ds-stack-tight {
    gap: 16px;
}

/* Server list: space between filter/export blocks and table */
.ds-list-section {
    margin-bottom: 16px;
}

.ds-row-between {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (min-width: 768px) {
    .ds-row-between {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }
}

.ds-form-head {
    margin-bottom: 20px;
}

.ds-form-head .ds-page-title {
    margin-bottom: 4px;
}

.ds-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.ds-actions form {
    display: inline;
}

/* ----- Chips / badges ----- */
.ds-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 980px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.01em;
    background: var(--chip-bg);
    color: var(--text-secondary);
    border: 1px solid var(--chip-border);
}

/* ----- Buttons ----- */
.ds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 8px;
    font-family: var(--font-text);
    font-size: 17px;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.022em;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
}

/* Match <a> and <button> metrics (UA button styles differ by browser) */
button.ds-btn {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
}

.ds-btn:focus-visible {
    outline: 2px solid var(--sk-focus-color);
    outline-offset: 2px;
}

.ds-btn--primary {
    background: var(--accent);
    color: #ffffff;
}

.ds-btn--primary:hover {
    background: var(--accent-hover);
}

.ds-btn--primary:active {
    background: #006edb;
}

.ds-btn--dark {
    background: #1d1d1f;
    color: #ffffff;
}

.ds-btn--dark:hover {
    background: #2d2d2f;
}

html[data-theme="dark"] .ds-btn--dark {
    background: #f5f5f7;
    color: #1d1d1f;
}

html[data-theme="dark"] .ds-btn--dark:hover {
    background: #ffffff;
}

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

.ds-btn--secondary:hover {
    background: var(--surface-muted);
}

/* Light “utility” control — same box model as primary/secondary (1px border, 17px type) so clusters align */
.ds-btn--filter {
    background: #fafafc;
    color: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border-field);
    border-radius: 8px;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.2;
}

html[data-theme="dark"] .ds-btn--filter {
    background: var(--surface-raised);
    color: var(--text-secondary);
}

.ds-btn--filter:hover {
    background: #ededf2;
}

html[data-theme="dark"] .ds-btn--filter:hover {
    background: var(--surface-muted);
}

.ds-btn--danger {
    background: var(--surface);
    color: var(--status-danger);
    border-color: var(--border-field);
}

.ds-btn--danger:hover {
    background: var(--status-danger-bg);
}

.ds-btn--icon {
    min-width: 36px;
    padding-left: 10px;
    padding-right: 10px;
}

.ds-btn--sm {
    min-height: 32px;
    padding: 6px 12px;
    font-size: 12px;
    letter-spacing: -0.01em;
}

/* ----- Panels & fields ----- */
.ds-panel {
    background: var(--surface);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow-card);
}

.ds-panel--flat {
    box-shadow: none;
    border: 1px solid var(--border-hairline);
}

.ds-field-grid {
    display: grid;
    gap: 16px;
}

@media (min-width: 768px) {
    .ds-field-grid--2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.ds-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.29;
    letter-spacing: -0.016em;
    color: var(--text-primary);
}

.ds-input,
.ds-select,
.ds-textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 11px;
    border: 3px solid var(--filter-border);
    background: #fafafc;
    color: var(--text-primary);
    font-family: var(--font-text);
    font-size: 14px;
    line-height: 1.43;
    letter-spacing: -0.016em;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

html[data-theme="dark"] .ds-input,
html[data-theme="dark"] .ds-select,
html[data-theme="dark"] .ds-textarea {
    background: var(--surface-muted);
    border-color: var(--filter-border);
    color: var(--text-primary);
}

.ds-input:focus-visible,
.ds-select:focus-visible,
.ds-textarea:focus-visible {
    outline: none;
    border-color: rgba(0, 113, 227, 0.45);
    box-shadow: 0 0 0 2px var(--sk-focus-color);
}

.ds-input:disabled,
.ds-textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background: var(--surface-muted);
}

.ds-hint {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.33;
    letter-spacing: -0.01em;
    color: var(--text-tertiary);
}

.ds-toggle-group {
    padding: 14px 16px;
    border-radius: 8px;
    background: var(--surface-muted);
    border: 1px solid var(--border-hairline);
}

.ds-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.ds-text-center {
    text-align: center;
}

.ds-modal-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

/* ----- Toggles (checkbox.switch) ----- */
.toggle {
    appearance: none;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: var(--toggle-off);
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s ease;
    cursor: pointer;
    border: none;
}

.toggle:focus-visible {
    outline: 2px solid var(--sk-focus-color);
    outline-offset: 2px;
}

.toggle::after {
    content: "";
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ffffff;
    position: absolute;
    top: 2px;
    left: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.toggle:checked {
    background: #0071e3;
}

.toggle:checked::after {
    transform: translateX(18px);
}

.toggle:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ----- Links ----- */
.ds-link {
    color: var(--link);
    text-decoration: none;
    font-size: inherit;
}

.ds-link:hover {
    text-decoration: underline;
}

button.ds-link {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.ds-link--sm {
    font-size: 12px;
    letter-spacing: -0.01em;
}

.ds-view-note-btn {
    margin-top: 6px;
}

/* ----- Table ----- */
.ds-table-wrap {
    overflow: hidden;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-hairline);
}

.ds-table-scroll {
    overflow-x: auto;
}

.ds-table {
    width: 100%;
    min-width: 56rem;
    border-collapse: collapse;
    font-size: 14px;
    line-height: 1.43;
    letter-spacing: -0.016em;
    text-align: left;
}

/* Server list: stable columns so DNS/URLs never collapse to one-character width */
.servers-zebra-table {
    table-layout: fixed;
}

.servers-zebra-table th:nth-child(1),
.servers-zebra-table td:nth-child(1) {
    width: 11%;
    min-width: 9rem;
}

.servers-zebra-table th:nth-child(2),
.servers-zebra-table td:nth-child(2) {
    width: 21%;
    min-width: 14rem;
}

.servers-zebra-table th:nth-child(3),
.servers-zebra-table td:nth-child(3) {
    width: 10%;
    min-width: 7rem;
}

.servers-zebra-table th:nth-child(4),
.servers-zebra-table td:nth-child(4) {
    width: 8%;
    min-width: 5.5rem;
}

.servers-zebra-table th:nth-child(5),
.servers-zebra-table td:nth-child(5) {
    width: 6%;
    min-width: 4.5rem;
}

.servers-zebra-table th:nth-child(6),
.servers-zebra-table td:nth-child(6) {
    width: 10%;
    min-width: 7rem;
}

.servers-zebra-table th:nth-child(7),
.servers-zebra-table td:nth-child(7) {
    width: 12%;
    min-width: 9rem;
}

.servers-zebra-table th:nth-child(8),
.servers-zebra-table td:nth-child(8) {
    width: 9%;
    min-width: 8rem;
}

.servers-zebra-table th:nth-child(9),
.servers-zebra-table td:nth-child(9) {
    width: 13%;
    min-width: 11rem;
}

.ds-table thead {
    background: var(--surface-muted);
}

.ds-table thead th {
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-hairline);
}

.ds-table thead a {
    color: inherit;
    text-decoration: none;
}

.ds-table thead a:hover {
    color: var(--text-primary);
}

.ds-table tbody td {
    padding: 14px 16px;
    vertical-align: top;
    border-bottom: 1px solid var(--border-hairline);
    color: var(--text-secondary);
}

.ds-table tbody tr:last-child td {
    border-bottom: none;
}

.servers-zebra-table tbody tr:nth-child(odd) {
    background-color: var(--surface);
}

.servers-zebra-table tbody tr:nth-child(even) {
    background-color: var(--surface-row-alt);
}

@media (prefers-reduced-motion: no-preference) {
    .servers-zebra-table tbody tr {
        transition: background-color 0.15s ease;
    }
}

@media (hover: hover) {
    .servers-zebra-table tbody tr:hover {
        background-color: var(--table-row-hover);
    }
}

.ds-table .ds-td-strong {
    font-weight: 600;
    color: var(--text-primary);
}

.ds-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.ds-status-expired {
    color: var(--status-danger);
}

.ds-status-warn {
    color: var(--status-warn);
}

/* ----- Copy / icon buttons ----- */
.copy-cell-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.copy-cell-btn:hover {
    background: var(--surface-muted);
    color: var(--text-primary);
}

.copy-cell-btn:focus-visible {
    outline: 2px solid var(--sk-focus-color);
    outline-offset: 1px;
}

.copy-cell-btn.is-copied {
    color: var(--status-success-fg);
}

/* ----- Notes preview ----- */
.notes-preview {
    max-width: 18rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    line-height: 1.35;
    color: var(--text-secondary);
}

/* ----- Modal ----- */
.ds-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--modal-scrim);
}

.ds-modal.is-open {
    display: flex;
}

.ds-modal-card {
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    overflow: auto;
    border-radius: 12px;
    background: var(--surface);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.ds-modal-card pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: var(--font-text);
    font-size: 14px;
    line-height: 1.47;
    color: var(--text-secondary);
}

/* ----- Flashes ----- */
.ds-flash {
    margin-bottom: 12px;
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.43;
    letter-spacing: -0.016em;
    border: 1px solid var(--border-hairline);
}

.ds-flash--error {
    background: var(--status-danger-bg);
    color: var(--status-danger);
    border-color: transparent;
}

.ds-flash--success {
    background: rgba(0, 113, 227, 0.08);
    color: var(--text-primary);
    border-color: rgba(0, 113, 227, 0.2);
}

html[data-theme="dark"] .ds-flash--success {
    background: rgba(0, 113, 227, 0.15);
    color: var(--text-primary);
}

/* ----- Login hero ----- */
.ds-login-wrap {
    max-width: 420px;
    margin: 48px auto 0;
}

.ds-login-card {
    border-radius: 12px;
    padding: 40px 36px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-hairline);
}

.ds-login-card .ds-page-title {
    font-size: 1.75rem;
}

/* ----- Export panel ----- */
.ds-export-title {
    margin: 0 0 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
}

.ds-check-grid {
    display: grid;
    gap: 8px;
}

@media (min-width: 768px) {
    .ds-check-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.ds-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.ds-check input {
    accent-color: var(--accent);
}

/* ----- Filter form row ----- */
.ds-filter-form {
    display: grid;
    gap: 12px;
}

@media (min-width: 900px) {
    .ds-filter-form {
        grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) auto;
        align-items: end;
    }
}

.ds-filter-form .ds-input,
.ds-filter-form .ds-select {
    min-height: 44px;
}

.ds-cell-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    vertical-align: middle;
    min-width: 0;
    max-width: 100%;
}

.ds-cell-row .copy-cell-btn {
    flex-shrink: 0;
}

.ds-cell-row .ds-link-url {
    flex: 1 1 auto;
    min-width: 0;
}

/* Long URLs: wrap when needed; avoid break-all (causes single-character columns) */
.ds-link-url {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.4;
}

/* ----- Utilities ----- */
.hidden {
    display: none !important;
}

.block {
    display: block;
}

.uppercase-type {
    text-transform: uppercase;
}
