:root {
    --bg: #f4f8f7;
    --surface: #ffffff;
    --surface-soft: #f0f7f6;
    --text: #173b3a;
    --muted: #5d7675;
    --line: #d7e6e3;
    --primary: #0d9488;
    --primary-dark: #08766e;
    --accent: #d97706;
    --danger: #c2413b;
    --focus: rgba(13, 148, 136, .22);
    --radius: 16px;
    --shadow: 0 12px 30px rgba(21, 68, 64, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-width: 320px;
    background: radial-gradient(circle at top right, #dff5f1 0, transparent 34%), var(--bg);
    color: var(--text);
    font: 16px/1.55 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font: inherit; }
button, a, input { transition: border-color .18s ease, background-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease; }
button, a.primary, .secondary { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px max(20px, calc((100vw - 1180px) / 2));
    color: #fff;
    background: #123c3a;
    border-bottom: 3px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #123c3a; background: #5eead4; font-weight: 800; }
.topbar nav { display: flex; align-items: center; gap: 8px; }
.topbar nav a { padding: 9px 12px; border-radius: 9px; color: #d8eeeb; font-size: 14px; }
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }
.topbar nav a.logout { color: #fed7aa; }

.container { width: min(1180px, calc(100% - 32px)); margin: 34px auto; }
.page-intro { margin: 0 0 24px; }
.eyebrow { margin: 0 0 6px; color: var(--primary-dark); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.page-intro h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.15; letter-spacing: -.04em; }
.page-intro p { max-width: 650px; margin: 10px 0 0; color: var(--muted); }
.card { margin-bottom: 24px; padding: clamp(20px, 3vw, 32px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card h2 { margin: 0; font-size: clamp(21px, 3vw, 27px); letter-spacing: -.025em; }
.card h3 { margin: 30px 0 14px; padding-top: 22px; border-top: 1px solid var(--line); font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.req { color: var(--danger); }
.empty { margin: 0; padding: 24px; color: var(--muted); text-align: center; background: var(--surface-soft); border: 1px dashed var(--line); border-radius: 12px; }

.field { margin-bottom: 16px; }
.field label, .login-card label { display: block; margin-bottom: 7px; color: var(--text); font-size: 14px; font-weight: 700; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field input[type="text"], .field input[type="password"], .field input[type="file"], .login-card input, textarea {
    width: 100%; min-height: 46px; padding: 11px 13px; color: var(--text); background: #fff; border: 1px solid #bcd3d0; border-radius: 10px;
}
.field input[type="file"] { padding: 9px; }
.field input::placeholder { color: #88a09e; }
.field input:focus, .login-card input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); outline: none; }
textarea { min-height: 320px; resize: vertical; font: 13px/1.6 "SF Mono", Consolas, monospace; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
button, .secondary, a.primary { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 15px; color: var(--text); background: #fff; border: 1px solid #bcd3d0; border-radius: 10px; font-size: 14px; font-weight: 700; text-decoration: none; }
button:hover, .secondary:hover { background: var(--surface-soft); border-color: var(--primary); text-decoration: none; }
button.primary, a.primary { color: #fff; background: var(--primary); border-color: var(--primary); }
button.primary:hover, a.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); }
button.danger { color: var(--danger); border-color: #e6b8b4; }
button.danger:hover { background: #fff2f1; }
button.small, a.small { min-height: 34px; padding: 6px 10px; font-size: 12px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; min-width: 850px; border-collapse: collapse; font-size: 14px; }
th, td { padding: 13px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { color: var(--muted); background: var(--surface-soft); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfefd; }
.link-cell { min-width: 270px; }
.link-cell input { width: 100%; min-height: 34px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; }
.copy-btn { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; margin: 0; }
.mono, code { font-family: "SF Mono", Consolas, monospace; font-size: 12px; }
code { padding: 3px 7px; color: var(--primary-dark); background: var(--surface-soft); border-radius: 6px; overflow-wrap: anywhere; }
.public-link { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; width: 100%; margin-top: 4px; padding: 12px; color: var(--muted); background: var(--surface-soft); border-radius: 10px; font-size: 13px; }

.alert { margin-bottom: 18px; padding: 12px 15px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; font-weight: 600; }
.alert-success { color: #126047; background: #e0f7ec; border-color: #a8dfc4; }
.alert-error { color: #982f2a; background: #fff0ee; border-color: #efc2bd; }
.alert-warning { color: #8a5308; background: #fff7df; border-color: #f2d48d; }
.alert-info { color: #185b79; background: #e4f4fb; border-color: #b6deed; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(circle at 20% 10%, #23766e, transparent 34%), #123c3a; }
.login-card { width: min(100%, 410px); padding: clamp(24px, 6vw, 40px); background: var(--surface); border: 1px solid rgba(255,255,255,.25); border-radius: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.login-card form { margin-top: 24px; }
.login-card form button { width: 100%; margin-top: 8px; }
.footer { padding: 8px 16px 28px; text-align: center; }

.qr-modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(9, 35, 34, .72); }
.qr-dialog { position: relative; width: min(100%, 380px); padding: 28px; text-align: center; background: #fff; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.qr-dialog h3 { margin: 0 0 18px; }
.qr-dialog img { display: block; width: 280px; max-width: 100%; height: auto; margin: 0 auto 14px; }
.qr-dialog p { margin: 0; }
.qr-close { position: absolute; top: 10px; right: 12px; min-height: 36px; padding: 2px 10px; border: 0; background: transparent; color: var(--muted); font-size: 25px; }

@media (max-width: 760px) {
    .topbar { align-items: flex-start; padding: 12px 16px; }
    .topbar nav { gap: 2px; }
    .topbar nav a { padding: 7px 8px; font-size: 12px; }
    .container { width: min(100% - 20px, 600px); margin: 22px auto; }
    .row { grid-template-columns: 1fr; gap: 0; }
    .card { margin-bottom: 16px; padding: 20px 16px; border-radius: 14px; }
    textarea { min-height: 230px; }
    .responsive-table thead { display: none; }
    .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; min-width: 0; }
    .table-wrap { overflow: visible; border: 0; }
    .responsive-table tr { margin-bottom: 12px; padding: 12px 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; }
    .responsive-table td { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 12px; padding: 8px 0; text-align: right; overflow-wrap: anywhere; border-bottom: 1px solid var(--line); }
    .responsive-table td:last-child { border-bottom: 0; }
    .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; text-align: left; }
    .responsive-table .link-cell, .responsive-table .actions-cell { display: flex; justify-content: flex-end; flex-wrap: wrap; }
    .responsive-table .link-cell::before, .responsive-table .actions-cell::before { margin-right: auto; }
}
@media (max-width: 420px) {
    .brand { font-size: 16px; }
    .brand-mark { width: 30px; height: 30px; }
    .topbar nav a:not(.logout) { display: none; }
    .actions > * { flex: 1 1 auto; }
    .public-link .copy-btn { flex: 0 0 auto; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
