:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --card-bg: #ffffff;
    --border: #dde1e6;
    --text: #1f2430;
    --text-muted: #6b7280;
    --primary: #2b5fd9;
    --primary-hover: #1e46ab;
    --danger: #c0392b;
    --warn-bg: #fff4e5;
    --warn-text: #92400e;
    --radius: 8px;
}

* { box-sizing: border-box; }

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

a { color: var(--primary); }

.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; }

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}
.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 360px;
}
.login-card h1 { font-size: 20px; margin-top: 0; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.login-card input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}
.alert { padding: 10px 12px; border-radius: var(--radius); font-size: 13px; }
.alert-error { background: #fdecea; color: var(--danger); }

/* App shell */
#app { max-width: 1200px; margin: 0 auto; padding: 16px; }

.topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-email { color: var(--text-muted); font-size: 13px; }

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.summary-cards .card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}
.summary-cards .card strong { display: block; font-size: 22px; }
.summary-cards .card span { color: var(--text-muted); font-size: 12px; }
.summary-cards .card.warn { background: var(--warn-bg); color: var(--warn-text); }

.sync-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sync-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.sync-row span { color: var(--text-muted); font-size: 12px; margin-left: 6px; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.filters input, .filters select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: #fff;
}
.filters input[type="search"] { flex: 1; min-width: 180px; }

.table-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { cursor: pointer; user-select: none; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
th:hover { color: var(--text); }
tbody tr:hover { background: #fafbfc; cursor: pointer; }

.expiry-soon-30 { color: var(--danger); font-weight: 600; }
.expiry-soon-60 { color: #b8860b; font-weight: 600; }
.expiry-soon-90 { color: #7a7a00; }

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: #eef1f5;
    color: var(--text-muted);
}
.badge-live_site { background: #e6f4ea; color: #1e7e34; }
.badge-http_redirect, .badge-cloudflare_redirect { background: #e8f0fe; color: #1a56db; }
.badge-parked { background: #fff4e5; color: #92400e; }
.badge-no_dns, .badge-error { background: #fdecea; color: var(--danger); }

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-muted);
}
.pagination button {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 30, 0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 780px;
    width: 100%;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    background: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
}
.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
.modal-grid h3 { font-size: 13px; text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px; }
.modal-grid div { margin-bottom: 4px; font-size: 13px; }

.comments-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comments-list li { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.comment-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.comment-text { white-space: pre-wrap; margin-bottom: 6px; }

#newCommentText {
    width: 100%;
    min-height: 70px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    margin-bottom: 8px;
    resize: vertical;
}

@media (max-width: 480px) {
    .topbar { flex-direction: column; align-items: flex-start; }
    .filters input, .filters select { flex: 1 1 100%; }
}
