:root {
    --bg-page: #f2f6fd;
    --bg-page-accent: #e8efff;
    --bg-card: #ffffff;
    --bg-card-soft: #f8fbff;
    --ink-strong: #142036;
    --ink-main: #27354f;
    --ink-muted: #65748f;
    --line-soft: #d9e3f0;
    --brand: #165dff;
    --brand-dark: #0f45bf;
    --accent: #03b2cb;
    --danger: #d73d5c;
    --danger-soft: #ffe8ee;
    --info: #076a93;
    --info-soft: #def4ff;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --shadow-sm: 0 6px 14px rgba(21, 39, 71, 0.08);
    --shadow-md: 0 14px 32px rgba(21, 39, 71, 0.12);
    --shadow-lg: 0 26px 60px rgba(21, 39, 71, 0.16);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    color: var(--ink-main);
    font-family: "Manrope", "Noto Sans TC", sans-serif;
    background:
        radial-gradient(circle at 5% -10%, #d3ebff 0%, transparent 38%),
        radial-gradient(circle at 90% -15%, #dff8ff 0%, transparent 42%),
        linear-gradient(180deg, var(--bg-page-accent) 0%, var(--bg-page) 45%, #ffffff 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3, h4 {
    margin: 0;
    color: var(--ink-strong);
    letter-spacing: 0.2px;
}

p {
    margin: 0;
    line-height: 1.65;
    color: var(--ink-main);
}

small,
.muted {
    color: var(--ink-muted);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 22px;
    background: linear-gradient(125deg, #0f1c35, #122746 58%, #0f3a5c);
    box-shadow: 0 10px 24px rgba(6, 15, 31, 0.25);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 240px;
}

.brand-dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(125deg, #00ccff, #58ffe2);
    box-shadow: 0 0 0 6px rgba(113, 226, 255, 0.2);
}

.brand-title {
    color: #f7fbff;
    font-weight: 900;
    font-size: 18px;
    line-height: 1.1;
}

.brand-subtitle {
    color: #bbd3f3;
    font-size: 12px;
    font-weight: 600;
    margin-top: 2px;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.topnav a {
    color: #b7cced;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 999px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.topnav a:hover,
.topnav a.active {
    background: rgba(141, 173, 220, 0.2);
    color: #ffffff;
}

.user-box {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.user-email {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #d8e8ff;
    font-size: 13px;
    font-weight: 600;
}

.nav-toggle {
    display: none;
}

.layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: calc(100vh - 70px);
}

.sidebar {
    background: linear-gradient(180deg, #111e36 0%, #10253d 100%);
    color: #dceaff;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-title {
    font-size: 11px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #8fb4e3;
    margin: 4px 8px 8px;
}

.sidebar a {
    display: block;
    padding: 11px 12px;
    border-radius: 12px;
    color: #d7e9ff;
    font-size: 14px;
    font-weight: 700;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.sidebar a:hover,
.sidebar a.active {
    background: rgba(176, 209, 255, 0.17);
}

.content {
    padding: 26px;
}

.site-footer {
    padding: 14px 20px 18px;
    border-top: 1px solid #d9e6f6;
    background: rgba(255, 255, 255, 0.84);
}

.site-footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 13px;
    color: #4b6384;
    font-weight: 700;
}

.site-footer-links a {
    color: #3e5d85;
}

.site-footer-links a:hover,
.site-footer-links a.active {
    color: var(--brand);
}

.card {
    background: linear-gradient(180deg, #ffffff, #fbfdff);
    border: 1px solid rgba(28, 71, 137, 0.08);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.card-title {
    font-size: 20px;
    font-weight: 900;
}

.card-subtitle {
    margin-top: 4px;
    color: var(--ink-muted);
    font-size: 14px;
}

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

.stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stack ul {
    margin: 0;
    padding-left: 20px;
}

.stack li {
    line-height: 1.65;
    color: var(--ink-main);
}

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

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

.metric {
    border-radius: var(--radius-md);
    padding: 16px;
    color: #f3f8ff;
    background: linear-gradient(130deg, #1b4cc8, #0089bf);
    box-shadow: var(--shadow-sm);
}

.metric .label {
    font-size: 13px;
    color: rgba(241, 247, 255, 0.9);
    font-weight: 700;
}

.metric .value {
    margin-top: 8px;
    font-size: 30px;
    line-height: 1;
    font-weight: 900;
}

.alert {
    margin-bottom: 12px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    padding: 12px 14px;
    line-height: 1.5;
    font-size: 14px;
    font-weight: 700;
}

.alert-info {
    background: var(--info-soft);
    border-color: #bde7fb;
    color: var(--info);
}

.alert-error {
    background: var(--danger-soft);
    border-color: #ffd1db;
    color: var(--danger);
}

form {
    display: grid;
    gap: 12px;
}

label {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 800;
    color: var(--ink-main);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: #ffffff;
    color: var(--ink-main);
    padding: 11px 12px;
    font-size: 14px;
    transition: border-color 0.15s ease, box-shadow 0.2s ease;
}

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

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #7ab2ff;
    box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.18);
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary {
    color: #ffffff;
    background: linear-gradient(130deg, var(--brand), #1978ff);
    box-shadow: 0 8px 18px rgba(22, 93, 255, 0.26);
}

.btn-secondary {
    color: #234270;
    background: #ecf4ff;
    border: 1px solid #cadcf6;
}

.btn-ghost {
    color: #d9e9ff;
    background: rgba(174, 205, 246, 0.15);
    border: 1px solid rgba(174, 205, 246, 0.25);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid #d3e2f6;
    background: #eff6ff;
    color: #30527e;
}

.btn-icon:hover {
    background: #e1efff;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    color: #21578d;
    background: #e3f2ff;
    border: 1px solid #cbe7ff;
}

.table-wrap {
    overflow: auto;
    border-radius: 14px;
    border: 1px solid #dce7f6;
    background: #ffffff;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid #ebf2fc;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    color: #1d3e69;
    background: #f2f7ff;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #f8fbff;
}

td small {
    color: var(--ink-muted);
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dashboard-toolbar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.dashboard-toolbar .field {
    flex: 1;
    min-width: 220px;
}

.dashboard-toolbar .actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

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

.line-info-list {
    margin-bottom: 8px;
}

.line-info-item {
    border: 1px solid #e3edf9;
    border-radius: 12px;
    padding: 10px 12px;
    background: #f9fcff;
}

.line-info-label {
    font-size: 12px;
    color: #5c7394;
    font-weight: 800;
    margin-bottom: 4px;
}

.line-info-value {
    font-size: 14px;
    color: #18345d;
    font-weight: 700;
    word-break: break-word;
}

.line-pill-success {
    color: #116148;
    background: #dff7ee;
    border-color: #b9ebd9;
}

.line-pill-muted {
    color: #4f678a;
    background: #eaf2ff;
    border-color: #d2e2fb;
}

.line-bind-panel {
    margin-top: 12px;
    border: 1px dashed #bad2f6;
    border-radius: 14px;
    background: #f4f9ff;
    padding: 12px;
}

.line-bind-title {
    font-size: 13px;
    font-weight: 800;
    color: #29507f;
}

.line-bind-code {
    margin-top: 6px;
    margin-bottom: 6px;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 1px;
    color: #114999;
}

.line-bind-command-wrap {
    margin-top: 10px;
    margin-bottom: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.line-bind-command {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #cddff9;
    background: #ffffff;
    color: #1c4678;
    font-weight: 800;
    font-family: "Consolas", "Menlo", monospace;
}

.line-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.line-checkbox-row label {
    margin: 0;
}

.date-range {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.card-flex {
    flex: 1;
    min-width: 360px;
}

.dashboard-row-200 .card-flex {
    min-height: 230px;
    display: flex;
    flex-direction: column;
}

.dashboard-row-200 .card-flex h3 {
    margin-bottom: 10px;
}

.rating-dist {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
}

.rating-row {
    display: grid;
    grid-template-columns: 64px 1fr 44px;
    align-items: center;
    gap: 10px;
}

.rating-label,
.rating-count {
    font-size: 13px;
    font-weight: 800;
    color: #244a79;
}

.rating-count {
    text-align: right;
}

.rating-bar {
    height: 11px;
    border-radius: 999px;
    background: #e0ecfa;
    overflow: hidden;
}

.rating-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(130deg, var(--accent), var(--brand));
}

#wordcloud-wrap {
    flex: 1;
    min-height: 120px;
}

#wordcloud {
    width: 100%;
    height: 100%;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal[aria-hidden="true"] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 22, 41, 0.55);
    backdrop-filter: blur(2px);
}

.modal-dialog {
    position: relative;
    width: min(780px, 96vw);
    max-height: min(86vh, 900px);
    overflow: auto;
    border-radius: 20px;
    border: 1px solid rgba(188, 210, 238, 0.7);
    background: #ffffff;
    box-shadow: var(--shadow-lg);
}

.modal-dialog.modal-lg {
    width: min(1020px, 96vw);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid #e8f0fd;
    padding: 14px 16px;
}

.modal-title {
    font-size: 18px;
    font-weight: 900;
    color: #1f3a61;
}

.modal-body {
    padding: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 0 2px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(14, 26, 48, 0.35);
}

.loading-card {
    width: min(520px, 100%);
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 16px;
    border: 1px solid #dce8f7;
    background: #ffffff;
    padding: 14px 16px;
    box-shadow: var(--shadow-md);
}

.spinner {
    width: 25px;
    height: 25px;
    border-radius: 999px;
    border: 3px solid #d7e8ff;
    border-top-color: var(--brand);
    animation: spin 0.85s linear infinite;
    flex-shrink: 0;
}

.loading-text {
    color: var(--ink-main);
    font-size: 14px;
    font-weight: 800;
}

.auth-layout {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 28px;
}

.auth-panel {
    width: min(740px, 100%);
    border-radius: 24px;
    border: 1px solid rgba(164, 196, 238, 0.55);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 251, 255, 0.98));
    box-shadow: var(--shadow-md);
    padding: 26px;
}

.auth-brand {
    font-size: 27px;
    font-weight: 900;
    color: #113664;
}

.auth-subtitle {
    margin-top: 8px;
    margin-bottom: 18px;
    color: #557092;
    line-height: 1.6;
}

.auth-card {
    border-radius: 16px;
    border: 1px solid #dbe8f8;
    background: #ffffff;
    padding: 18px;
}

.auth-card h2 {
    font-size: 22px;
    font-weight: 900;
}

.auth-card .desc {
    margin-top: 6px;
    margin-bottom: 10px;
    color: var(--ink-muted);
}

.legal-note {
    margin-top: 12px;
    font-size: 13px;
    color: #4f6888;
}

.legal-note a {
    color: var(--brand);
    font-weight: 800;
}

.legal-note a:hover {
    text-decoration: underline;
}

.toast-wrap {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 2000;
    display: grid;
    gap: 8px;
}

.toast {
    border-radius: 12px;
    padding: 10px 12px;
    min-width: 220px;
    background: #11284b;
    color: #f2f7ff;
    font-size: 13px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    animation: toast-in 0.2s ease-out;
}

.toast.success {
    background: #165dff;
}

.toast.error {
    background: #d73d5c;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    font-size: 13px;
    color: var(--ink-muted);
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #d3e2f4;
    border-radius: 10px;
    padding: 6px 10px;
    background: #ffffff;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
    border: 1px solid transparent !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #eaf3ff !important;
    border-color: #cce0fc !important;
    color: #1f4d86 !important;
}

button.dt-button,
div.dt-button,
a.dt-button {
    border-radius: 10px !important;
    border: 1px solid #c6daf8 !important;
    background: #eef5ff !important;
    color: #214776 !important;
    box-shadow: none !important;
}

button.dt-button:hover,
div.dt-button:hover,
a.dt-button:hover {
    background: #deecff !important;
}

@media (max-width: 1200px) {
    .topnav {
        display: none;
    }

    .nav-toggle {
        display: inline-flex;
    }

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

    .sidebar {
        position: fixed;
        top: 70px;
        left: 0;
        width: min(280px, 86vw);
        height: calc(100vh - 70px);
        transform: translateX(-110%);
        transition: transform 0.2s ease;
        z-index: 99;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
}

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

    .card {
        padding: 16px;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .card-flex {
        min-width: 100%;
    }

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

@media (max-width: 640px) {
    .topbar {
        padding: 12px 14px;
    }

    .brand {
        min-width: 0;
    }

    .brand-title {
        font-size: 16px;
    }

    .brand-subtitle,
    .user-email {
        display: none;
    }

    .rating-row {
        grid-template-columns: 52px 1fr 36px;
        gap: 8px;
    }

    .rating-label,
    .rating-count {
        font-size: 12px;
    }
}
