/* ==========================================================================
   远程录音笔管理后台 · 无外部依赖样式
   ========================================================================== */

:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --sidebar: #0d1628;
    --sidebar-soft: #13203a;
    --text: #0f172a;
    --text-soft: #334155;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --line: #e2e8f0;
    --line-soft: #edf2f7;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --green: #16a34a;
    --green-soft: #ecfdf5;
    --amber: #d97706;
    --amber-soft: #fffbeb;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --violet: #7c3aed;
    --violet-soft: #f5f3ff;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.035);
    --shadow-lg: 0 30px 80px rgba(2, 6, 23, 0.35);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

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

button,
input,
select,
textarea {
    font-family: inherit;
}

svg {
    display: block;
}

code,
.mono {
    font-family: var(--mono);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   应用框架
   -------------------------------------------------------------------------- */

.app-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 100% 0, rgba(37, 99, 235, 0.055), transparent 32rem),
        var(--bg);
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: 264px;
    padding: 22px 15px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    color: #cbd5e1;
    background:
        radial-gradient(circle at 20% 0, rgba(59, 130, 246, 0.18), transparent 18rem),
        linear-gradient(180deg, #0d1628 0%, #0b1323 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.09);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 8px 24px;
}

.brand-mark {
    position: relative;
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 42px;
    height: 42px;
    background: linear-gradient(145deg, #3b82f6, #1d4ed8);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 13px;
    box-shadow: 0 10px 24px rgba(29, 78, 216, 0.35);
}

.brand-mark span {
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.14);
}

.brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.35;
}

.brand-copy strong {
    overflow: hidden;
    color: #f8fafc;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-copy small {
    color: #7f8ea8;
    font-size: 11px;
    letter-spacing: 0.16em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-section-label {
    padding: 4px 12px 8px;
    color: #62718c;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    overflow: hidden;
    color: #aab7cc;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 10px;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nav-link:hover {
    color: #fff;
    background: rgba(148, 163, 184, 0.08);
}

.nav-link.is-active {
    color: #fff;
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.24), rgba(37, 99, 235, 0.08));
    border-color: rgba(96, 165, 250, 0.18);
}

.nav-link.is-active::before {
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 0;
    width: 3px;
    background: #60a5fa;
    border-radius: 0 4px 4px 0;
    content: "";
}

.nav-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 21px;
    height: 21px;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.65;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 26px 5px 0;
    padding: 13px 12px;
    background: rgba(148, 163, 184, 0.055);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 11px;
}

.sidebar-note-dot {
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    margin-top: 6px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

.sidebar-note strong,
.sidebar-note small {
    display: block;
}

.sidebar-note strong {
    color: #d7e2f1;
    font-size: 11.5px;
    font-weight: 600;
}

.sidebar-note small {
    color: #74839c;
    font-size: 10.5px;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.admin-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 7px 12px;
}

.admin-avatar {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    color: #dbeafe;
    font-size: 13px;
    font-weight: 700;
    background: rgba(59, 130, 246, 0.16);
    border: 1px solid rgba(96, 165, 250, 0.22);
    border-radius: 10px;
}

.admin-chip-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.4;
}

.admin-chip-copy strong {
    overflow: hidden;
    color: #e2e8f0;
    font-size: 12.5px;
    font-weight: 600;
    text-overflow: ellipsis;
}

.admin-chip-copy small {
    color: #74839c;
    font-size: 10.5px;
}

.btn-sidebar {
    width: 100%;
    padding: 8px 12px;
    color: #93a3ba;
    font-size: 12px;
    font-weight: 500;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 9px;
    cursor: pointer;
    transition: 0.16s ease;
}

.btn-sidebar:hover {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.09);
    border-color: rgba(248, 113, 113, 0.24);
}

.app-main {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    margin-left: 264px;
}

.top-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 17px 34px 0;
    color: var(--muted);
    font-size: 11.5px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb strong {
    color: var(--text-soft);
    font-weight: 600;
}

.breadcrumb span[aria-hidden] {
    color: #cbd5e1;
}

.top-strip-meta {
    color: var(--muted-light);
}

.content {
    width: 100%;
    max-width: 1480px;
    flex: 1;
    margin: 0 auto;
    padding: 22px 34px 46px;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: 16px 34px 24px;
    color: var(--muted-light);
    font-size: 11.5px;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
}

.mobile-bar {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

/* --------------------------------------------------------------------------
   标题、按钮、表单
   -------------------------------------------------------------------------- */

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

.page-head h1 {
    margin: 0;
    color: var(--text);
    font-size: 27px;
    font-weight: 750;
    letter-spacing: -0.025em;
    line-height: 1.25;
}

.page-subtitle {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 3px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 15px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    white-space: nowrap;
    text-align: center;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus-visible,
.page-link:focus-visible,
.nav-link:focus-visible,
summary:focus-visible,
a:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.7);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-color: #1d4ed8;
    box-shadow: 0 5px 14px rgba(37, 99, 235, 0.22);
}

.btn-primary:hover {
    color: #fff;
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    border-color: #1e40af;
    box-shadow: 0 7px 18px rgba(37, 99, 235, 0.28);
}

.btn-secondary {
    color: var(--text-soft);
    background: var(--surface);
    border-color: var(--line);
}

.btn-secondary:hover {
    color: var(--primary-dark);
    background: #f8fbff;
    border-color: #bfdbfe;
}

.btn-ghost {
    color: var(--muted);
    background: transparent;
    border-color: transparent;
}

.btn-ghost:hover {
    color: var(--text-soft);
    background: #f1f5f9;
}

.btn-danger {
    color: #b91c1c;
    background: #fff;
    border-color: #fecaca;
}

.btn-danger:hover {
    color: #fff;
    background: #dc2626;
    border-color: #dc2626;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 11.5px;
    border-radius: 7px;
}

.btn-block {
    width: 100%;
}

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

.field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 600;
}

.required {
    color: var(--red);
}

.field input,
.field select,
.field textarea,
.filter-grid input,
.filter-grid select {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    background: #fff;
    border: 1px solid #dbe3ed;
    border-radius: 9px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.filter-grid input:focus,
.filter-grid select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
}

.field input::placeholder {
    color: #a7b2c2;
}

.field-help {
    color: var(--muted-light);
    font-size: 11.5px;
    line-height: 1.5;
}

.form-stack {
    display: grid;
    gap: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field-wide {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 3px;
}

/* --------------------------------------------------------------------------
   提示、面板、状态
   -------------------------------------------------------------------------- */

.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 14px;
    color: var(--text-soft);
    font-size: 13px;
    white-space: pre-line;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 11px;
    box-shadow: var(--shadow-sm);
}

.flash-marker {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin-top: 7px;
    background: var(--muted-light);
    border-radius: 50%;
}

.flash-text {
    min-width: 0;
    flex: 1;
    word-break: break-word;
}

.flash-close {
    flex: 0 0 auto;
    padding: 0 3px;
    color: var(--muted-light);
    font-size: 18px;
    line-height: 1;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.flash-close:hover {
    color: var(--text);
}

.flash-success {
    color: #166534;
    background: var(--green-soft);
    border-color: #bbf7d0;
}

.flash-success .flash-marker {
    background: #22c55e;
}

.flash-warning {
    color: #92400e;
    background: var(--amber-soft);
    border-color: #fde68a;
}

.flash-warning .flash-marker {
    background: #f59e0b;
}

.flash-error {
    color: #991b1b;
    background: var(--red-soft);
    border-color: #fecaca;
}

.flash-error .flash-marker {
    background: #ef4444;
}

.flash-info {
    color: #1e40af;
    background: var(--primary-soft);
    border-color: #bfdbfe;
}

.flash-info .flash-marker {
    background: #3b82f6;
}

.flash-static {
    box-shadow: none;
}

.alert {
    margin-bottom: 18px;
    padding: 13px 15px;
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.alert-error {
    color: #991b1b;
    background: var(--red-soft);
    border-color: #fecaca;
}

.panel {
    margin-bottom: 22px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line-soft);
}

.panel-head h2 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    color: var(--text);
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.panel-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.link-arrow {
    flex: 0 0 auto;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
}

.link-arrow:hover {
    text-decoration: underline;
}

.count-pill {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 700;
    background: var(--primary-soft);
    border-radius: 99px;
}

.subtext {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.5;
}

.device-name {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.error-text {
    color: #b91c1c;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-line {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 600;
}

.status-dot {
    display: inline-block;
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
}

.status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}

.status-dot.offline {
    background: #cbd5e1;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.55;
    white-space: nowrap;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 99px;
}

.badge-success {
    color: #15803d;
    background: var(--green-soft);
    border-color: #dcfce7;
}

.badge-warning {
    color: #a16207;
    background: #fefce8;
    border-color: #fef08a;
}

.badge-info {
    color: #1d4ed8;
    background: var(--primary-soft);
    border-color: #dbeafe;
}

.badge-danger {
    color: #b91c1c;
    background: var(--red-soft);
    border-color: #fee2e2;
}

.badge-muted {
    color: #64748b;
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.badge-soft {
    border-color: transparent;
}

.pulse-dot {
    width: 5px;
    height: 5px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

/* --------------------------------------------------------------------------
   仪表盘
   -------------------------------------------------------------------------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    position: relative;
    min-width: 0;
    padding: 19px 20px 17px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-card::after {
    position: absolute;
    top: -50px;
    right: -40px;
    width: 140px;
    height: 140px;
    background: var(--accent-soft, rgba(37, 99, 235, 0.08));
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.stat-card-blue {
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.07);
}

.stat-card-green {
    --accent: #16a34a;
    --accent-soft: rgba(22, 163, 74, 0.07);
}

.stat-card-amber {
    --accent: #d97706;
    --accent-soft: rgba(217, 119, 6, 0.08);
}

.stat-card-violet {
    --accent: #7c3aed;
    --accent-soft: rgba(124, 58, 237, 0.07);
}

.stat-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stat-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.stat-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 10px;
}

.stat-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.stat-value {
    position: relative;
    z-index: 1;
    margin-top: 12px;
    color: var(--text);
    font-size: 31px;
    font-weight: 750;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.stat-unit {
    margin-left: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
}

.stat-meta {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    color: var(--muted);
    font-size: 11.5px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.9fr);
    gap: 20px;
    align-items: start;
}

.device-list {
    padding: 5px 22px 12px;
    margin: 0;
    list-style: none;
}

.device-list-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line-soft);
}

.device-list-item:last-child {
    border-bottom: 0;
}

.device-avatar {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 36px;
    height: 36px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.device-avatar.is-online {
    background: var(--green-soft);
    border-color: #dcfce7;
}

.device-list-main {
    min-width: 0;
    flex: 1;
}

.device-list-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.device-list-title strong {
    overflow: hidden;
    font-size: 12.5px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 4px;
}

.quick-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 17px;
    color: var(--text-soft);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.quick-card:hover {
    color: var(--text);
    border-color: #c7d7ef;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.07);
    text-decoration: none;
    transform: translateY(-2px);
}

.quick-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 36px;
    height: 36px;
    color: var(--primary);
    font-size: 16px;
    font-weight: 600;
    background: var(--primary-soft);
    border-radius: 10px;
}

.quick-card strong,
.quick-card small {
    display: block;
}

.quick-card strong {
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 600;
}

.quick-card small {
    margin-top: 1px;
    color: var(--muted);
    font-size: 11px;
}

/* --------------------------------------------------------------------------
   表格
   -------------------------------------------------------------------------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    padding: 10px 14px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

.table td {
    padding: 13px 14px;
    color: var(--text-soft);
    font-size: 12px;
    vertical-align: top;
    border-bottom: 1px solid var(--line-soft);
}

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

.table tbody tr:hover {
    background: #fbfdff;
}

.table th:first-child,
.table td:first-child {
    padding-left: 22px;
}

.table th:last-child,
.table td:last-child {
    padding-right: 22px;
}

.devices-table {
    min-width: 1000px;
}

.recordings-table {
    min-width: 1100px;
}

.th-actions,
.td-actions {
    width: 1%;
    white-space: nowrap;
}

.th-audio {
    width: 240px;
}

.device-cell {
    display: flex;
    min-width: 160px;
    flex-direction: column;
    gap: 1px;
}

.device-cell-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.device-cell-title strong {
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
}

.device-note {
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    max-width: 330px;
}

.inline-menu {
    display: inline-block;
}

.inline-menu > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 10px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.35;
    list-style: none;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    transition: 0.16s ease;
}

.inline-menu > summary::-webkit-details-marker {
    display: none;
}

.inline-menu > summary::after {
    font-size: 8px;
    content: "▼";
}

.inline-menu > summary:hover {
    color: var(--text-soft);
    background: #f1f5f9;
}

.inline-menu[open] {
    flex-basis: 100%;
}

.inline-menu[open] > summary {
    color: var(--text-soft);
    background: #f1f5f9;
    border-color: var(--line);
}

.inline-menu-body {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px 0 2px;
}

.table audio {
    display: block;
    width: 220px;
    max-width: 100%;
    height: 34px;
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
}

.filename {
    display: block;
    max-width: 205px;
    overflow: hidden;
    font-family: var(--mono);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   筛选、添加面板、空状态
   -------------------------------------------------------------------------- */

.filter-panel {
    padding: 18px 22px;
}

.filter-grid {
    display: grid;
    grid-template-columns: minmax(150px, 1.15fr) minmax(135px, 0.85fr) minmax(135px, 0.85fr) minmax(180px, 1.2fr) auto;
    gap: 12px;
    align-items: end;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 1px;
}

.add-panel {
    overflow: visible;
}

.add-panel > summary {
    list-style: none;
}

.add-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
}

.add-summary::-webkit-details-marker {
    display: none;
}

.add-summary-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    color: var(--primary);
    font-size: 18px;
    font-weight: 500;
    background: var(--primary-soft);
    border-radius: 9px;
}

.add-summary strong,
.add-summary small {
    display: block;
}

.add-summary strong {
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
}

.add-summary small {
    color: var(--muted);
    font-size: 11.5px;
}

.chevron {
    width: 8px;
    height: 8px;
    margin-left: auto;
    border-right: 1.7px solid var(--muted-light);
    border-bottom: 1.7px solid var(--muted-light);
    transform: rotate(45deg);
    transition: transform 0.18s ease;
}

.add-panel[open] .chevron {
    transform: rotate(225deg);
}

.add-body {
    padding: 20px 22px 22px;
    border-top: 1px solid var(--line-soft);
}

.empty-state {
    padding: 48px 24px;
    text-align: center;
}

.empty-state.compact {
    padding: 32px 22px;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 13px;
    color: #7c93b5;
    background: #f1f6fd;
    border-radius: 15px;
}

.empty-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.empty-state h3 {
    margin: 0 0 5px;
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 650;
}

.empty-state p {
    max-width: 440px;
    margin: 0 auto 14px;
    color: var(--muted);
    font-size: 12px;
}

.empty-state p a {
    font-weight: 600;
}

.notice {
    padding: 15px 17px;
    color: #92400e;
    font-size: 12px;
    background: #fffdf5;
    border: 1px solid #fde68a;
    border-left: 3px solid #f59e0b;
    border-radius: 10px;
}

.notice strong {
    display: block;
    margin-bottom: 3px;
    color: #78350f;
    font-size: 12px;
}

.notice p {
    margin: 0;
    color: #a16207;
    line-height: 1.65;
}

/* --------------------------------------------------------------------------
   分页
   -------------------------------------------------------------------------- */

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 17px 20px;
    border-top: 1px solid var(--line-soft);
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 30px;
    padding: 0 9px;
    color: var(--text-soft);
    font-size: 11.5px;
    font-weight: 500;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 7px;
    transition: 0.15s ease;
}

a.page-link:hover {
    color: var(--primary-dark);
    background: #f8fbff;
    border-color: #bfdbfe;
    text-decoration: none;
}

.page-link.current {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.page-link.disabled {
    color: #cbd5e1;
    background: #f8fafc;
    border-color: var(--line-soft);
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   登录页
   -------------------------------------------------------------------------- */

.login-body {
    min-height: 100vh;
    margin: 0;
    padding: 32px 16px;
    background:
        radial-gradient(circle at 12% 16%, rgba(37, 99, 235, 0.28), transparent 30rem),
        radial-gradient(circle at 90% 80%, rgba(14, 165, 233, 0.12), transparent 26rem),
        #08101f;
}

.login-shell {
    display: grid;
    grid-template-columns: 1.02fr 0.98fr;
    width: min(980px, 100%);
    min-height: 590px;
    margin: 0 auto;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
}

.login-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 42px 40px 30px;
    overflow: hidden;
    color: #e2e8f0;
    background:
        radial-gradient(circle at 90% 8%, rgba(59, 130, 246, 0.3), transparent 20rem),
        radial-gradient(circle at 0% 100%, rgba(14, 165, 233, 0.13), transparent 24rem),
        linear-gradient(145deg, #101d36, #0b1526 70%);
}

.login-hero::after {
    position: absolute;
    right: -90px;
    bottom: -110px;
    width: 330px;
    height: 330px;
    border: 1px solid rgba(96, 165, 250, 0.18);
    border-radius: 50%;
    box-shadow:
        0 0 0 36px rgba(96, 165, 250, 0.04),
        0 0 0 76px rgba(96, 165, 250, 0.025);
    content: "";
    pointer-events: none;
}

.login-hero-inner {
    position: relative;
    z-index: 1;
}

.brand-on-dark {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 56px;
}

.brand-text {
    color: #f1f5f9;
    font-size: 16px;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.login-hero h1 {
    margin: 0;
    color: #f8fafc;
    font-size: 36px;
    font-weight: 750;
    letter-spacing: -0.035em;
    line-height: 1.28;
}

.login-hero p {
    max-width: 340px;
    margin: 17px 0 0;
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.8;
}

.login-points {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    margin: 32px 0 0;
    color: #aab7cc;
    font-size: 12px;
    list-style: none;
}

.login-points li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-points li span {
    color: #60a5fa;
    font-size: 7px;
}

.login-hero-foot {
    position: relative;
    z-index: 1;
    color: #64748b;
    font-size: 10.5px;
    letter-spacing: 0.04em;
}

.login-panel {
    display: flex;
    align-items: center;
    padding: 42px 46px;
    background: #fff;
}

.login-panel-inner {
    width: 100%;
    max-width: 350px;
    margin: 0 auto;
}

.login-heading {
    margin-bottom: 24px;
}

.eyebrow {
    display: block;
    margin-bottom: 9px;
    color: var(--primary);
    font-size: 9.5px;
    font-weight: 750;
    letter-spacing: 0.19em;
}

.login-heading h2 {
    margin: 0;
    color: var(--text);
    font-size: 24px;
    font-weight: 750;
    letter-spacing: -0.025em;
}

.login-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.login-help {
    margin: 22px 0 0;
    color: var(--muted-light);
    font-size: 10.5px;
    line-height: 1.7;
}

.login-help code {
    padding: 1px 4px;
    color: #475569;
    font-size: 9.5px;
    background: #f1f5f9;
    border-radius: 4px;
}

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-actions {
        grid-column: 1 / -1;
    }
}

@media (min-width: 961px) {
    body.sidebar-open {
        overflow: auto;
    }
}

@media (max-width: 960px) {
    .sidebar {
        width: 280px;
        transform: translateX(-102%);
        transition: transform 0.22s ease;
    }

    .app-main {
        margin-left: 0;
    }

    .mobile-bar {
        position: sticky;
        top: 0;
        z-index: 30;
        display: flex;
        align-items: center;
        gap: 11px;
        min-height: 56px;
        padding: 0 18px;
        background: rgba(255, 255, 255, 0.94);
        border-bottom: 1px solid var(--line);
        backdrop-filter: blur(10px);
    }

    .mobile-brand {
        min-width: 0;
        overflow: hidden;
        color: var(--text-soft);
        font-size: 13px;
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-status-dot {
        width: 7px;
        height: 7px;
        margin-left: auto;
        background: #22c55e;
        border-radius: 50%;
        box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
    }

    .icon-btn {
        display: inline-grid;
        flex: 0 0 auto;
        place-items: center;
        width: 34px;
        height: 34px;
        padding: 0;
        color: var(--text-soft);
        background: #f8fafc;
        border: 1px solid var(--line);
        border-radius: 9px;
        cursor: pointer;
    }

    .menu-lines {
        display: flex;
        flex-direction: column;
        gap: 3px;
        width: 15px;
    }

    .menu-lines span {
        display: block;
        width: 100%;
        height: 1.5px;
        background: currentColor;
        border-radius: 2px;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 35;
        display: block;
        visibility: hidden;
        background: rgba(2, 6, 23, 0.5);
        opacity: 0;
        transition: opacity 0.22s ease, visibility 0.22s ease;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 18px 0 50px rgba(2, 6, 23, 0.3);
    }

    body.sidebar-open .sidebar-backdrop {
        visibility: visible;
        opacity: 1;
    }

    .top-strip {
        display: none;
    }

    .content {
        padding: 22px 22px 36px;
    }

    .app-footer {
        padding: 14px 22px 22px;
    }

    .login-shell {
        grid-template-columns: 1fr;
        width: min(460px, 100%);
        min-height: auto;
    }

    .login-hero {
        padding: 28px 28px 24px;
    }

    .brand-on-dark {
        margin-bottom: 24px;
    }

    .login-hero h1 {
        font-size: 26px;
    }

    .login-hero p,
    .login-points {
        display: none;
    }

    .login-hero-foot {
        display: none;
    }

    .login-panel {
        padding: 30px 28px 34px;
    }
}

@media (max-width: 720px) {
    .content {
        padding: 18px 16px 30px;
    }

    .app-footer {
        flex-direction: column;
        gap: 3px;
        align-items: flex-start;
        padding: 14px 16px 20px;
    }

    .page-head {
        flex-direction: column;
        gap: 13px;
        margin-bottom: 18px;
    }

    .page-head h1 {
        font-size: 23px;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }

    .panel-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 7px;
        padding: 16px;
    }

    .stats-grid {
        gap: 11px;
    }

    .stat-card {
        padding: 15px 16px;
    }

    .stat-value {
        font-size: 26px;
    }

    .quick-grid {
        grid-template-columns: 1fr;
    }

    .filter-panel {
        padding: 16px;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        grid-column: auto;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .field-wide {
        grid-column: auto;
    }

    .add-body {
        padding: 16px;
    }

    .table th:first-child,
    .table td:first-child {
        padding-left: 16px;
    }

    .table th:last-child,
    .table td:last-child {
        padding-right: 16px;
    }

    .flash {
        font-size: 12px;
    }

    .login-body {
        padding: 18px 12px;
    }

    .login-shell {
        border-radius: 18px;
    }

    .login-hero {
        padding: 22px 22px 20px;
    }

    .login-panel {
        padding: 25px 22px 28px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .device-actions {
        max-width: 220px;
    }

    .top-strip-meta {
        display: none;
    }

    .page-actions {
        flex-direction: column;
    }

    .page-actions .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
