:root {
    --bg: #0f1419;
    --panel: #1a2029;
    --panel-2: #232b36;
    --border: #2d3644;
    --text: #e6e9ef;
    --muted: #8a94a6;
    --accent: #4dabf7;
    --accent-2: #339af0;
    --danger: #f06565;
    --warn: #f0c14c;
    --ok: #51cf66;
    --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 32px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 15px; }
nav { display: flex; gap: 4px; flex: 1; }
nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
}
nav a:hover { background: var(--panel-2); color: var(--text); }
nav a.active { background: var(--accent); color: white; }

.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.logout .user { color: var(--muted); font-size: 13px; }
.logout button {
    background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
    padding: 4px 12px; border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
.logout button:hover { background: var(--panel); }

main { max-width: 1200px; margin: 0 auto; padding: 24px 32px; }

h1 { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
h2 { margin: 28px 0 12px; font-size: 16px; font-weight: 600; color: var(--text); }
.muted { color: var(--muted); margin: 4px 0 20px; font-size: 13px; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; font-size: 12px; font-family: ui-monospace, Menlo, monospace; }

.flash {
    list-style: none; margin: 16px 32px; padding: 12px 16px;
    background: #1e3a3a; border: 1px solid #2d5555;
    border-radius: var(--radius); color: #8ef0c8;
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0 28px; }
.card {
    background: var(--panel); border: 1px solid var(--border);
    padding: 16px; border-radius: var(--radius);
}
.card.warn { border-color: var(--warn); }
.card .n { font-size: 28px; font-weight: 600; color: var(--text); }
.card .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

table {
    width: 100%; border-collapse: collapse; background: var(--panel);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--panel-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; }
td { font-size: 13px; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.reason { color: var(--warn); font-family: ui-monospace, monospace; font-size: 12px; }

.form-card {
    background: var(--panel); border: 1px solid var(--border);
    padding: 20px; border-radius: var(--radius); margin: 24px 0;
}
.form-card h2 { margin-top: 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label small { font-weight: normal; color: var(--muted); }
input, select {
    padding: 8px 10px; font-size: 13px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

button {
    background: var(--accent); color: white; border: 0;
    padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500;
}
button:hover { background: var(--accent-2); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.danger:hover { background: var(--danger); color: white; }

form.inline { display: inline-flex; gap: 6px; margin-right: 6px; }
form.inline select { padding: 4px 8px; font-size: 12px; }
form.inline button { padding: 4px 10px; font-size: 12px; }

.login {
    max-width: 360px; margin: 80px auto; padding: 32px;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.login h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login .muted { text-align: center; margin-bottom: 24px; }
.login label { margin-bottom: 14px; }
.login button { width: 100%; padding: 10px; font-size: 14px; }

/* SMTP page: owner cards */
.owner-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); margin: 16px 0; overflow: hidden;
}
.owner-card.warn { border-color: var(--warn); }
.owner-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; background: var(--panel-2); border-bottom: 1px solid var(--border);
    gap: 16px;
}
.owner-name { font-size: 16px; font-weight: 600; }
.owner-head .small { font-size: 12px; }
.owner-head code { font-size: 12px; }
.owner-actions { display: flex; gap: 8px; }
.owner-actions form { margin: 0; }

.edit-form { padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.edit-form.hidden { display: none; }

.ghl-table { width: 100%; border: none; border-radius: 0; background: transparent; }
.ghl-table th { background: transparent; border-bottom: 1px solid var(--border); }
.ghl-table td { padding: 8px 14px; vertical-align: middle; }
.ghl-table input, .ghl-table select { width: 100%; font-size: 12px; padding: 6px 8px; }
.ghl-table .mono { font-family: ui-monospace, Menlo, monospace; }
.ghl-table .actions { white-space: nowrap; display: flex; gap: 4px; }
.ghl-table tr.add-row { background: rgba(77, 171, 247, 0.05); }
.ghl-table tr.add-row td { border-top: 1px dashed var(--border); }

button.small { padding: 4px 10px; font-size: 12px; }
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--panel); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.page-head h1 { margin-bottom: 4px; }
.page-head-action { margin: 6px 0 0; }
.page-head-action button { padding: 8px 16px; font-size: 13px; }
.page-head-action button:disabled { opacity: 0.6; cursor: wait; }

/* Resync modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 9999; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.modal.hidden { display: none; }
.modal-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); width: min(880px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,0.5); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--panel-2); border-radius: var(--radius) var(--radius) 0 0; }
.modal-head h2 { margin: 0 0 4px; font-size: 16px; }
.modal-phase { color: var(--muted); font-size: 12px; }
.modal-body { padding: 16px 20px; overflow: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; justify-content: flex-end; gap: 8px; }
.modal-summary { margin-top: 12px; padding: 10px 14px; background: rgba(77, 171, 247, 0.08); border: 1px solid rgba(77,171,247,0.2); border-radius: 6px; font-size: 13px; }
.modal-summary:empty { display: none; }

.phase-block { margin-bottom: 14px; }
.phase-label { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.phase-label .phase-counts { color: var(--muted); font-size: 12px; }
.phase-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.phase-dot.active { background: var(--accent); box-shadow: 0 0 0 4px rgba(77,171,247,0.2); animation: phase-pulse 1.2s ease-in-out infinite; }
.phase-dot.done { background: var(--ok); }
@keyframes phase-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.progress-bar { position: relative; height: 14px; background: var(--panel-2); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.25s ease; }
.progress-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; mix-blend-mode: screen; }

.log-label { display: flex; gap: 8px; align-items: baseline; margin: 14px 0 6px; font-size: 12px; }
.log-window {
    height: 320px; overflow: auto; background: var(--bg); border: 1px solid var(--border);
    border-radius: 6px; padding: 8px 10px; font-family: ui-monospace, Menlo, monospace;
    font-size: 11.5px; line-height: 1.5;
}
.log-line { padding: 2px 0; border-bottom: 1px solid rgba(45,54,68,0.4); }
.log-line:last-child { border-bottom: none; }
.log-line code { background: transparent; padding: 0; color: var(--accent); font-size: 11.5px; }
.log-line.meta { color: var(--muted); font-style: italic; }
.log-line.folder { color: var(--accent); }
.log-line.folder-done { color: var(--muted); }
.log-line.ok { color: var(--text); }
.log-line.ok.override strong { color: var(--warn); }
.log-line.email { background: rgba(81, 207, 102, 0.04); }
.log-line.skip { color: var(--muted); }
.log-line.err { color: var(--danger); }
.log-line .tag { background: var(--warn); color: var(--bg); padding: 0 4px; border-radius: 3px; font-size: 10px; font-weight: 600; }
.log-line .ok-tag { background: var(--ok); color: var(--bg); padding: 0 5px; border-radius: 3px; font-size: 10px; font-weight: 600; margin-right: 4px; }

.small { font-size: 12px; }
summary { cursor: pointer; padding: 6px 0; }
details[open] summary { margin-bottom: 8px; }
