/* 域名资产档案系统 — hand-written stylesheet.
   No build step on purpose: the server runs nginx + PHP only, and a deploy
   should never depend on npm being present. */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #dfe3e8;
    --text: #1f2933;
    --text-dim: #6b7684;
    --accent: #2f6fed;
    --accent-dark: #1f57c9;
    --danger: #d92d20;
    --danger-bg: #fef3f2;
    --warn: #b54708;
    --warn-bg: #fffaeb;
    --ok: #027a48;
    --ok-bg: #ecfdf3;
    --radius: 6px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- Login ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 32px 28px;
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.06);
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 20px;
}

.login-card .subtitle {
    margin: 0 0 24px;
    color: var(--text-dim);
    font-size: 13px;
}

/* ---------- Forms ---------- */

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
}

.field .hint {
    display: block;
    margin-top: 4px;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 400;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(47, 111, 237, 0.25);
    border-color: var(--accent);
}

textarea {
    min-height: 84px;
    resize: vertical;
}

.field-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.field-inline input {
    width: auto;
    margin: 0;
}

.field-inline label {
    margin: 0;
    font-weight: 400;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.btn:hover {
    background: var(--accent-dark);
    text-decoration: none;
}

.btn-block {
    width: 100%;
}

.btn-secondary {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #f0f2f5;
}

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

.btn-danger:hover {
    background: #b42318;
}

/* ---------- Messages ---------- */

.alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid #fecdca;
    color: var(--danger);
}

.alert-warn {
    background: var(--warn-bg);
    border: 1px solid #fedf89;
    color: var(--warn);
}

.alert-ok {
    background: var(--ok-bg);
    border: 1px solid #a6f4c5;
    color: var(--ok);
}

.field-error {
    display: block;
    margin-top: 4px;
    color: var(--danger);
    font-size: 12px;
}

/* ---------- App shell ---------- */

.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topnav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.brand {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
}

.brand:hover {
    text-decoration: none;
}

.navlinks {
    display: flex;
    gap: 16px;
    flex: 1;
}

.navlinks a {
    color: var(--text-dim);
    font-weight: 600;
}

.navlinks a.active {
    color: var(--accent);
}

.logout-form {
    margin: 0;
}

.page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px;
}

.page h1 {
    font-size: 18px;
    margin: 0 0 16px;
}

/* ---------- Tables ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data th,
table.data td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

table.data th {
    background: #fafbfc;
    font-weight: 600;
    color: var(--text-dim);
    white-space: nowrap;
}

table.data tbody tr:last-child td {
    border-bottom: 0;
}

table.data tbody tr:hover {
    background: #fbfcfd;
}

.muted {
    color: var(--text-dim);
}

.nowrap {
    white-space: nowrap;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-warn {
    background: var(--warn-bg);
    color: var(--warn);
}

.badge-none {
    background: #f1f3f5;
    color: var(--text-dim);
}

/* ---------- Empty state ---------- */

.empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-dim);
}

.empty p {
    margin: 0 0 12px;
}

/* ---------- Page header ---------- */

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.page-head h1 {
    margin: 0;
}

/* ---------- Form card ---------- */

.form-card {
    padding: 20px;
    max-width: 640px;
}

/* Buttons that belong to one decision sit on one line, whatever form each of
   them submits — two stacked buttons read as two unrelated steps. */
.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

/* Long-form help that would otherwise be a wall of text under a single input.
   The one sentence that matters stays visible; the paragraph explaining when
   the setting applies is one click away. */
details.hint-more {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

details.hint-more summary {
    cursor: pointer;
    color: var(--accent);
    width: fit-content;
}

details.hint-more p {
    margin: 8px 0 0;
    line-height: 1.7;
}

details.hint-more p + p {
    margin-top: 6px;
}

/* A closing line inside a form card: what this setting currently affects.
   A one-row definition list was the first attempt and read as a mistake —
   its 120px label column leaves a gap wide enough to look like missing data. */
.card-footnote {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.card-footnote > .label {
    color: var(--text-dim);
}

/* ---------- Inline row actions ---------- */

.inline-form {
    display: inline;
    margin: 0;
}

.linkbtn {
    background: none;
    border: 0;
    padding: 0;
    margin-left: 10px;
    font: inherit;
    color: var(--accent);
    cursor: pointer;
}

.linkbtn:hover {
    text-decoration: underline;
}

.linkbtn-danger {
    color: var(--danger);
}

/* ---------- Horizontally scrollable table ---------- */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Input with a fixed unit ---------- */

/* The unit sits outside the box because it is not editable: what the user
   types is the figure, and the archive supplies the rest. */
.field-unit {
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-unit .unit {
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
}

/* ---------- Multi-column field row ---------- */

.field-row {
    display: flex;
    gap: 12px;
}

.field-row .field {
    flex: 1;
}

/* ---------- Filter bar ---------- */

.filterbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 13px;
}

.filterbar label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filterbar input[type="checkbox"] {
    width: auto;
}

/* Controls in a filter bar size to their content. Without this they inherit the
   form-wide width:100% and the provider dropdown swallows the whole row,
   pushing the button into a two-line wrap. */
.filterbar select {
    width: auto;
    min-width: 140px;
    max-width: 220px;
}

.filterbar .btn {
    white-space: nowrap;
}

.filterbar label {
    white-space: nowrap;
}

/* Released names stay visible but visibly inactive. */
tr.row-released td {
    color: var(--text-dim);
    background: #fafbfc;
}

/* ---------- Detail page ---------- */

.detail-card {
    padding: 4px 20px 16px;
}

dl.detail {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0;
    margin: 0;
}

dl.detail dt {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 13px;
}

dl.detail dd {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    margin: 0;
}

dl.detail dt:last-of-type,
dl.detail dd:last-of-type {
    border-bottom: 0;
}

.section-title {
    font-size: 15px;
    margin: 24px 0 12px;
}

/* ---------- Change log timeline ---------- */

ul.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul.timeline li {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 16px;
    align-items: baseline;
    font-size: 13px;
}

ul.timeline li:last-child {
    border-bottom: 0;
}

.timeline-time {
    color: var(--text-dim);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.timeline-body {
    display: flex;
    gap: 10px;
    align-items: baseline;
    flex-wrap: wrap;
}

.timeline-field {
    font-weight: 600;
}

/* Numeric cells line up when digits are tabular. */
td.num {
    font-variant-numeric: tabular-nums;
}

/* ---------- Expiry urgency bands ---------- */

table.data tbody tr.row-warning td {
    background: #fff4ed;
}

table.data tbody tr.row-warning:hover td {
    background: #ffeadd;
}

table.data tbody tr.row-critical td {
    background: #fde7e5;
}

table.data tbody tr.row-critical:hover td {
    background: #fbd9d6;
}

/* Released wins over the urgency bands: it is not costing money any more. */
table.data tbody tr.row-released td,
table.data tbody tr.row-released:hover td {
    background: #fafbfc;
    color: var(--text-dim);
}

/* ---------- Summary bar ---------- */

.summary {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.summary-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 20px;
    min-width: 140px;
}

.summary-label {
    color: var(--text-dim);
    font-size: 12px;
}

.summary-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.summary-value.is-alert {
    color: var(--danger);
}

/* The 要你手动续 tile is the only one that goes anywhere, so it is the only
   one that looks clickable — the rest are readouts and must not invite a
   click that does nothing. */
.summary-item-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color .12s, box-shadow .12s;
}

.summary-item-link:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.summary-item-link.is-alert-card {
    border-color: var(--danger);
}

/* 自动续费 on the form: a checkbox that decides whether a domain is a task,
   so it gets a box of its own rather than a line in a row of text fields. */
.field-flag {
    background: var(--surface-alt, #f8f9fa);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
    margin: 0;
}

/* ---------- Sortable headers ---------- */

table.data th a {
    color: inherit;
    display: inline-block;
}

table.data th.sorted {
    color: var(--accent);
}

.sort-arrow {
    margin-left: 4px;
    font-size: 10px;
}

.search-input {
    width: 220px;
}

.nav-count {
    display: inline-block;
    margin-left: 4px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
}

.alert a {
    color: inherit;
    text-decoration: underline;
}

/* ---------- Narrow screens ----------
   The table takes care of itself inside .table-scroll; what needs help is the
   furniture around it, which would otherwise break mid-word on a phone. */

.navlinks a,
.brand {
    white-space: nowrap;
}

@media (max-width: 720px) {
    .topnav-inner {
        flex-wrap: wrap;
        gap: 10px 14px;
        padding: 10px 14px;
    }

    .navlinks {
        order: 3;
        flex-basis: 100%;
        gap: 14px;
    }

    .page {
        padding: 14px;
    }

    .page-head {
        flex-wrap: wrap;
    }

    .filterbar {
        flex-wrap: wrap;
    }

    .filterbar .search-input,
    .filterbar select {
        width: 100%;
        max-width: none;
    }

    .summary-item {
        flex: 1 1 100px;
        min-width: 0;
        padding: 10px 14px;
    }

    .summary-value {
        font-size: 18px;
    }

    dl.detail {
        grid-template-columns: 84px 1fr;
    }
}

/* 列显示选择器（机器列表）。收起时只是一行文字，不占版面；
   展开后是一片复选框，用 grid 自动排列，窄屏自然折行。 */
.column-picker {
    margin: 0 0 14px;
    font-size: 13px;
}

.column-picker > summary {
    cursor: pointer;
    color: var(--text-dim);
    padding: 4px 0;
    user-select: none;
}

.column-picker > summary:hover {
    color: var(--accent);
}

.column-picker form {
    margin-top: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.column-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px 16px;
    margin-bottom: 12px;
}

.column-picker-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.column-picker-grid input[type="checkbox"] {
    margin: 0;
}

/* 上传框（导出/导入页）。浏览器给的默认控件在别的输入框旁边显得太小，
   所以按其它输入框的边框与内边距对齐，只是把"选择文件"按钮留给浏览器画。 */
input[type="file"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 13px;
}
