* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-soft: #e9fbf8;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --bg: #eef8f7;
    --card-bg: #ffffff;
    --border: #e5edf4;
    --border-strong: #d7e2ec;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.06);
    --radius: 18px;
}

body {
    min-height: 100vh;
    font-family: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(circle at 38% 8%, rgba(20, 184, 166, 0.18), transparent 34rem),
        linear-gradient(135deg, #f8fcfc 0%, var(--bg) 48%, #f7fbfb 100%);
    color: var(--text);
    line-height: 1.6;
}

button, input, select, textarea { font: inherit; }

html, body, .modal, .nav-tabs {
    scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.nav-tabs::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.table-wrap::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-wrap::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.table-wrap::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.table-wrap {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.app-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.96);
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.03);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px 28px;
    flex-shrink: 0;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #ccfbf1, #f0fdfa);
    color: var(--primary-hover);
    font-size: 22px;
    font-weight: 900;
    box-shadow: 0 10px 26px rgba(20, 184, 166, 0.22);
}

.brand-block h1 {
    color: var(--text);
    font-size: 22px;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.brand-block p { display: none; }

.nav-tabs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-bottom: 8px;
}

.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-group-toggle {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    border: none;
    background: transparent;
    color: #334155;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
}

.nav-group-toggle span {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.nav-group-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.nav-group-arrow {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.18s ease;
}

.nav-group.open .nav-group-arrow {
    transform: rotate(90deg);
}

.nav-group-items {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding-left: 16px;
}

.nav-group.open .nav-group-items {
    display: flex;
}

.nav-tab {
    width: 100%;
    min-height: 50px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 0 22px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-tab svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: currentColor;
}

.nav-tab span { display: none; }

.nav-tab strong {
    font-size: 15px;
    font-weight: 700;
}

.nav-tab:hover {
    transform: translateX(2px);
    background: #f0fdfa;
    color: var(--primary-hover);
}

.nav-tab.active {
    background: var(--primary-soft);
    color: var(--primary);
    box-shadow: none;
}

.workspace {
    min-width: 0;
    padding: 0 28px 28px;
}

.workspace-header {
    position: sticky;
    top: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 -28px 28px;
    padding: 18px 38px;
    border-bottom: 1px solid var(--border);
    background: rgba(248, 252, 252, 0.94);
    backdrop-filter: blur(18px);
}

.eyebrow {
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.workspace-header h2 {
    margin: 0;
    color: var(--text);
    font-size: 25px;
    line-height: 1.15;
    font-weight: 900;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    font-size: 20px;
}

.profile-menu { position: relative; }

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text);
}

.profile-avatar {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: #14b8a6;
    color: #ffffff;
    font-size: 18px;
    font-weight: 900;
}

.profile-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.profile-text strong { font-size: 16px; }
.profile-text small { color: var(--text-secondary); font-size: 13px; }
.profile-chevron {
    color: var(--text-muted);
    line-height: 0;
}

.profile-chevron svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    width: 240px;
    display: none;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.16);
}

.profile-menu.open .profile-dropdown { display: block; }

.profile-dropdown-head {
    padding: 16px 18px;
    border-bottom: 1px solid #eef2f7;
}

.profile-dropdown-head strong,
.profile-dropdown-head small { display: block; }
.profile-dropdown-head small { margin-top: 2px; color: var(--text-secondary); }

.profile-dropdown button {
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-bottom: 1px solid #eef2f7;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
}

.profile-dropdown button:hover { background: #f8fafc; }
.profile-dropdown button:last-child { border-bottom: none; }
.profile-dropdown .dropdown-danger { color: var(--danger); }

.main-container {
    max-width: 1510px;
    margin: 0 auto;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    flex-shrink: 0;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}

.theme-toggle strong {
    min-width: 32px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    text-align: center;
}

body.dark-mode {
    --bg: #0f172a;
    --card-bg: #111827;
    --border: #263244;
    --border-strong: #334155;
    --text: #e5eef8;
    --text-secondary: #9fb0c4;
    --text-muted: #64748b;
    background: linear-gradient(135deg, #08111f 0%, #0f172a 55%, #111827 100%);
}

body.dark-mode .sidebar,
body.dark-mode .workspace-header,
body.dark-mode .card,
body.dark-mode .stat-card,
body.dark-mode .toolbar,
body.dark-mode .table-wrap,
body.dark-mode .modal,
body.dark-mode .profile-dropdown,
body.dark-mode .theme-toggle {
    background: #111827;
    color: var(--text);
    border-color: var(--border);
}

body.dark-mode th,
body.dark-mode .modal-header,
body.dark-mode .modal-footer {
    background: #172033;
}

body.dark-mode td,
body.dark-mode .profile-dropdown button {
    background: #111827;
    color: var(--text);
    border-color: var(--border);
}

body.dark-mode tr:hover td {
    background: #1e293b;
    color: #f8fafc;
}

body.dark-mode tr:hover .cell-url,
body.dark-mode tr:hover strong {
    color: #5eead4;
}

body.dark-mode .stat-label,
body.dark-mode .eyebrow,
body.dark-mode .empty-text,
body.dark-mode .pagination,
body.dark-mode .form-group label,
body.dark-mode .detail-item .detail-label,
body.dark-mode .profile-text small,
body.dark-mode .profile-dropdown-head small {
    color: #cbd5e1;
}

body.dark-mode .toolbar input,
body.dark-mode .toolbar select,
body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea {
    background: #0f172a;
    color: #e5eef8;
    border-color: #334155;
}

body.dark-mode .toolbar input::placeholder,
body.dark-mode .form-group input::placeholder,
body.dark-mode .form-group textarea::placeholder {
    color: #94a3b8;
}

body.dark-mode .btn {
    background: #172033;
    color: #e5eef8;
    border-color: #334155;
}

body.dark-mode .btn-primary {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    color: #ffffff;
}

body.dark-mode .btn-danger {
    color: #fecaca;
    border-color: #7f1d1d;
}

body.dark-mode .app-dialog {
    background: #111827;
    color: #e5eef8;
}

body.dark-mode .app-dialog p {
    color: #cbd5e1;
}

.tab-content { display: none; }

.cell-link {
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}
.cell-link:hover { text-decoration: underline; }
body.dark-mode .cell-link { color: #5eead4; }
