:root {
    --bg: #f5f7fa;
    --card: #fff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success-bg: #ecfdf5;
    --success-border: #10b981;
    --msg-bg: #eff6ff;
    --msg-border: #2563eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans CJK TC', sans-serif;
    background: var(--bg);
    color: var(--text);
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5em 1em 3em;
    line-height: 1.5;
    font-size: 16px;
}

h1 { margin: 0 0 0.5em; font-size: 1.75em; }
h2 { margin: 1.8em 0 0.6em; font-size: 1.25em; color: var(--text); border-bottom: 2px solid var(--border); padding-bottom: 0.3em; }
h3 { margin: 1.4em 0 0.5em; font-size: 1.05em; }
p { margin: 0.6em 0; }

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

code {
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    font-size: 0.88em;
    background: #f3f4f6;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    word-break: break-all;
}

.topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.6em;
    margin-bottom: 0.5em;
    font-size: 0.92em;
    color: var(--muted);
}

.msg {
    background: var(--msg-bg);
    border-left: 4px solid var(--msg-border);
    padding: 0.7em 1em;
    border-radius: 4px;
    margin: 1em 0;
}
.msg.err { background: #fef2f2; border-left-color: var(--danger); color: var(--danger); }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
th, td {
    padding: 0.7em 0.9em;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
th { background: #f9fafb; font-weight: 600; font-size: 0.88em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: 0; }

button, input[type=submit] {
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 0.55em 1em;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    min-height: 40px;
    font-family: inherit;
}
button:hover { background: var(--accent-hover); }
button[type=submit][name=delete], button.danger { background: var(--danger); }
button[type=submit][name=delete]:hover, button.danger:hover { background: var(--danger-hover); }

form.inline { display: inline; }
form.inline button { margin-left: 0.4em; }

input[type=text], input[type=password], input:not([type]), textarea, select {
    width: 100%;
    padding: 0.6em 0.8em;
    font-size: 1em;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-family: inherit;
}
input[type=text]:focus, input[type=password]:focus, input:not([type]):focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
textarea { font-family: 'SF Mono', Consolas, Monaco, monospace; min-height: 200px; resize: vertical; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5em;
    box-shadow: var(--shadow);
    margin: 1em 0;
}

.hint { color: var(--muted); font-size: 0.88em; }

/* MOBILE: <= 600px — tables stack as cards, buttons full-width */
@media (max-width: 600px) {
    body { padding: 1em 0.6em 2em; font-size: 17px; }
    h1 { font-size: 1.45em; }
    h2 { font-size: 1.15em; }
    .topbar { justify-content: space-between; flex-wrap: wrap; }

    table, thead, tbody, tr, th, td { display: block; }
    thead { position: absolute; left: -9999px; }
    table { border: 0; box-shadow: none; background: transparent; }
    tr {
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 6px;
        margin-bottom: 0.7em;
        padding: 0.5em 0.8em;
        box-shadow: var(--shadow);
    }
    td {
        border-bottom: 1px dotted var(--border);
        padding: 0.5em 0;
    }
    td:last-child { border-bottom: 0; }
    td:before {
        content: attr(data-label);
        display: block;
        font-size: 0.75em;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-bottom: 0.2em;
    }

    button, input[type=submit] { width: 100%; margin: 0.3em 0; }
    form.inline { display: block; }
    form.inline button { margin-left: 0; }
}
