:root {
    --c-bg: #f5f5f5;
    --c-surface: #ffffff;
    --c-border: #e0e0e0;
    --c-text: #1a1a1a;
    --c-text-muted: #6b6b6b;
    --c-accent: #1a1a1a;
    --c-accent-contrast: #ffffff;
    --c-online: #2e7d32;
    --c-offline: #c62828;
    --c-danger: #c62828;
    --c-danger-bg: #fdecea;
    --c-warning: #8a6100;
    --c-warning-bg: #fff3cd;
    --c-warning-border: #ffe08a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
}

/* Top bar */
#cryptid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

#cryptid-header nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

#cryptid-header nav a {
    color: var(--c-text-muted);
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 500;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
    transition: color 150ms ease, border-color 150ms ease;
}

#cryptid-header nav a:hover {
    color: var(--c-text);
}

#cryptid-header nav a.active {
    color: var(--c-text);
    border-bottom-color: var(--c-accent);
}

#cryptid-header .cryptid-brand {
    text-align: right;
    line-height: 1.3;
}

/* Deploy/restart notice under the top bar (shared.js) */
.deploy-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 10px 24px;
    background: var(--c-warning-bg);
    border-bottom: 1px solid var(--c-warning-border);
    color: var(--c-warning);
    font-size: 0.95em;
}

.deploy-banner[hidden] {
    display: none;
}

#cryptid-header .cryptid-brand .name {
    font-weight: 700;
    font-size: 1.05em;
}

#cryptid-header .cryptid-brand .build {
    color: var(--c-text-muted);
    font-size: 0.8em;
}

#cryptid-header .cryptid-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    color: var(--c-text-muted);
}

#cryptid-header .cryptid-user a {
    color: var(--c-text-muted);
    text-decoration: none;
}

#cryptid-header .cryptid-user a:hover {
    color: var(--c-text);
}

#cryptid-header .cryptid-settings-link {
    font-size: 1.3em;
    text-decoration: none;
    color: var(--c-text-muted);
    line-height: 1;
}

#cryptid-header .cryptid-settings-link:hover {
    color: var(--c-text);
}

.cryptid-page {
    padding: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

h2, h3 {
    font-weight: 600;
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 20px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.03);
    overflow: hidden;
}

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

tbody tr {
    transition: background-color 150ms ease;
}

tbody tr:hover td {
    background: var(--c-bg);
}

th {
    background: var(--c-bg);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--c-text-muted);
}

input {
    width: 100%;
    border: none;
    background: transparent;
    font: inherit;
    color: inherit;
}

input:focus {
    outline: 1px solid var(--c-accent);
    background: var(--c-bg);
    transition: background-color 150ms ease;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

/* Buttons */
button {
    padding: 8px 14px;
    border: 1px solid var(--c-border);
    border-radius: 7px;
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

button:hover {
    background: var(--c-bg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

button:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn-danger {
    color: var(--c-danger);
    border-color: var(--c-danger);
}

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

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.warning-banner {
    display: none;
    background: var(--c-warning-bg);
    border: 1px solid var(--c-warning-border);
    color: var(--c-warning);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
}

/* Forms */
form {
    border: 1px solid var(--c-border);
    border-radius: 10px;
    padding: 16px;
    max-width: 420px;
    background: var(--c-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.03);
}

form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
    font-size: 0.9em;
    color: var(--c-text-muted);
}

form label:first-child {
    margin-top: 0;
}

form input,
form select {
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 8px 10px;
}

form button[type="submit"] {
    margin-top: 16px;
    width: 100%;
}

/* A form embedded directly in a modal (no border/padding of its own --
   the dialog already provides the visual boundary). Used instead of
   repeating the same inline style on every modal's <form>. */
.modal-form {
    margin: 18px;
    border: none;
    padding: 0;
    max-width: none;
    box-shadow: none;
}

.form-error {
    color: var(--c-offline);
    font-size: 0.9em;
    margin-top: 10px;
    display: none;
}

.ssl-badge {
    display: inline-block;
    background: var(--c-online);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.9em;
}

.status-online { color: var(--c-online); font-weight: 600; }
.status-offline { color: var(--c-offline); font-weight: 600; }
.status-unknown { color: var(--c-text-muted); }

/* Dashboard tiles */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.tile {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.03);
}

.tile h3 {
    margin: 0 0 14px 0;
    font-size: 1em;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tile-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.tile-stat .value {
    font-size: 2em;
    font-weight: 700;
    line-height: 1;
}

.tile-stat .label {
    font-size: 0.85em;
    color: var(--c-text-muted);
    margin-top: 4px;
}

.tile-sparkline-wrap {
    height: 36px;
    margin-top: 12px;
}

.tile a.tile-link {
    display: inline-block;
    margin-top: 16px;
    font-size: 0.9em;
    color: var(--c-text-muted);
    text-decoration: none;
}

.tile a.tile-link:hover {
    color: var(--c-text);
}

.metrics-range-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    margin-bottom: 10px;
}

.metrics-range-buttons button {
    padding: 4px 10px;
    font-size: 0.85em;
}

.metrics-range-buttons button.active {
    background: var(--c-accent);
    color: var(--c-accent-contrast);
    border-color: var(--c-accent);
}

.metrics-chart-wrap {
    position: relative;
    height: 140px;
}

.containers-section {
    margin-top: 32px;
}

.containers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.containers-header h2 {
    margin: 0;
}

.container-search {
    min-width: 220px;
}

.containers-no-match {
    color: var(--c-text-muted);
    margin-top: 12px;
}

.container-row {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
}

.container-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.container-env {
    color: var(--c-text-muted);
    font-size: 0.85em;
    margin-left: 6px;
}

.container-status {
    margin-left: 10px;
    font-size: 0.9em;
}

.container-build {
    color: var(--c-text-muted);
    font-size: 0.85em;
    margin-right: 10px;
}

.container-row-meta {
    margin-top: 10px;
    font-size: 0.85em;
    color: var(--c-text-muted);
}

.container-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.container-chart-wrap {
    position: relative;
    height: 120px;
}

.container-logs {
    margin-top: 16px;
}

.container-logs-panel {
    margin-top: 10px;
}

.container-logs-actions {
    margin-bottom: 8px;
}

.container-logs-output {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 12px;
    max-height: 260px;
    overflow-y: auto;
    font-size: 0.8em;
    white-space: pre-wrap;
    word-break: break-word;
}

.demand-chart-wrap {
    position: relative;
    height: 300px;
    margin-bottom: 20px;
}

.queue-modal {
    width: min(700px, 90vw);
    max-height: 80vh;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    padding: 0;
    background: var(--c-surface);
    color: var(--c-text);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Compact variant for modals holding a single short form (Add User,
   Reset Password, Add App) instead of the wide two-table Request Queue
   view -- avoids a two-field form looking lost in a 700px-wide dialog.
   Wide enough that the full 48-char API key mostly fits on 1-2 lines. */
.queue-modal.modal-sm {
    width: min(480px, 90vw);
}

.queue-modal::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.queue-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-border);
}

.queue-modal-header h3 {
    margin: 0;
}

.queue-modal-header button {
    background: none;
    border: none;
    font-size: 1.3em;
    line-height: 1;
    cursor: pointer;
    color: var(--c-text-muted);
}

.queue-modal h4 {
    margin: 16px 18px 6px;
}

/* A checkbox + label row (e.g. the Assign Apps list) */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.modal-details {
    margin: 16px 18px;
}

.modal-details dt,
.modal-details dd {
    margin: 0;
}

.modal-details dt {
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--c-text-muted);
    margin-top: 12px;
}

.modal-details dt:first-child {
    margin-top: 0;
}

.modal-details dd {
    margin-top: 2px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Long values that shouldn't overflow the modal (e.g. a full API key) */
.modal-details dd .value-chip {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85em;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 4px 8px;
    overflow-wrap: anywhere;
    word-break: break-all;
}

.queue-table {
    width: calc(100% - 36px);
    margin: 0 18px 16px;
    border-collapse: collapse;
}

.queue-table th, .queue-table td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--c-border);
    font-size: 0.9em;
}

.queue-content-full {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 240px;
    overflow-y: auto;
    margin: 6px 0 0;
    padding: 6px;
    background: var(--c-bg-alt, rgba(128, 128, 128, 0.08));
    border-radius: 4px;
    font-size: 0.85em;
}
