@import url('https://fonts.googleapis.com/css2?family=Chivo:wght@300;400;700;900&family=IBM+Plex+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5.9% 10%;
    --radius: 0.35rem;
    --success: 160 84% 39%;
    --success-soft: 151 81% 96%;
    --warning: 38 92% 50%;
    --warning-soft: 48 96% 89%;
    --info: 217 91% 60%;
    --info-soft: 214 100% 96%;
    --violet: 262 83% 58%;
    --violet-soft: 270 100% 97%;
    --rose-soft: 351 100% 96%;
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.05), 0 14px 32px rgba(15, 23, 42, 0.04);
    --sidebar-width: 16rem;
}

body.theme-dark {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 9% 8%;
    --card-foreground: 0 0% 98%;
    --popover: 240 9% 8%;
    --popover-foreground: 0 0% 98%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 10%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 240 4.9% 83.9%;
    --success-soft: 160 64% 16%;
    --warning-soft: 39 55% 20%;
    --info-soft: 217 55% 18%;
    --violet-soft: 267 38% 18%;
    --rose-soft: 344 44% 18%;
    --shadow-soft: 0 18px 48px rgba(0, 0, 0, 0.36);
    --shadow-card: 0 2px 14px rgba(0, 0, 0, 0.24);
}

* {
    box-sizing: border-box;
    border-color: hsl(var(--border));
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    transition: background-color 0.2s ease, color 0.2s ease;
}

html {
    color-scheme: light;
}

body.theme-dark {
    color-scheme: dark;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    font-family: 'Chivo', sans-serif;
}

p {
    margin: 0;
}

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

img {
    max-width: 100%;
}

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

button {
    cursor: pointer;
}

summary {
    list-style: none;
}

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

code,
pre,
.font-mono,
.stat-value,
.summary-card-value,
.recent-value {
    font-family: 'JetBrains Mono', monospace;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--muted-foreground) / 0.3);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--muted-foreground) / 0.5);
}

.icon {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
}

.auth-shell {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    overflow: hidden;
    background: hsl(var(--background));
}

.auth-gradient,
.auth-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.auth-gradient {
    background:
        radial-gradient(circle at top left, hsl(var(--info) / 0.12), transparent 30%),
        radial-gradient(circle at bottom right, hsl(var(--success) / 0.12), transparent 34%),
        linear-gradient(180deg, hsl(var(--muted) / 0.35), transparent);
}

.auth-grid {
    background-image:
        linear-gradient(to right, hsl(var(--border) / 0.25) 1px, transparent 1px),
        linear-gradient(to bottom, hsl(var(--border) / 0.25) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: radial-gradient(circle at center, black 30%, transparent 88%);
    opacity: 0.7;
}

.auth-stage {
    position: relative;
    z-index: 1;
    width: min(100%, 30rem);
}

.login-card {
    position: relative;
    display: grid;
    gap: 1.5rem;
    padding: 2rem;
    border: 1px solid hsl(var(--border) / 0.8);
    border-radius: calc(var(--radius) + 0.25rem);
    background: hsl(var(--card) / 0.94);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.login-brand {
    display: grid;
    gap: 1rem;
    justify-items: center;
    text-align: center;
}

.login-header-icon {
    display: grid;
    place-items: center;
    width: 4rem;
    height: 4rem;
    border-radius: calc(var(--radius) + 0.15rem);
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.login-header-icon .icon {
    width: 2rem;
    height: 2rem;
}

.login-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: calc(var(--radius) + 0.1rem);
}

.login-brand h1 {
    font-size: clamp(1.75rem, 5vw, 2.15rem);
    font-weight: 900;
    letter-spacing: -0.04em;
}

.eyebrow,
.sidebar-eyebrow,
.topbar-eyebrow,
.sidebar-meta,
.summary-card-title,
.toast-title,
.table-meta,
.mini-card-label {
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

.muted,
.helper-text,
.page-subtitle,
.panel-head p,
.stat-muted,
.recent-meta,
.user-menu-subtitle {
    color: hsl(var(--muted-foreground));
    line-height: 1.55;
}

.auth-copy {
    display: grid;
    gap: 0.3rem;
}

.auth-copy .muted {
    max-width: 28rem;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.input-group {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    color: hsl(var(--muted-foreground));
    pointer-events: none;
}

.input,
.select,
.textarea {
    width: 100%;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    padding: 0.75rem 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: hsl(var(--ring) / 0.4);
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.08);
}

.input.with-leading-icon {
    padding-left: 2.75rem;
}

.input.with-trailing-icon {
    padding-right: 3rem;
}

.textarea {
    min-height: 7rem;
    resize: vertical;
}

.password-toggle {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: hsl(var(--muted-foreground));
}

.password-toggle:hover {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.88rem;
    font-weight: 600;
}

.checkbox-row label,
.checkbox-list label {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: hsl(var(--foreground));
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: hsl(var(--foreground));
}

.checkbox-list {
    display: grid;
    gap: 0.7rem;
    padding: 1rem;
    border: 1px dashed hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--muted) / 0.35);
}

.button-row,
.inline-form,
.page-actions,
.panel-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.72rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1;
    transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.button-primary:hover {
    background: hsl(var(--primary) / 0.92);
}

.button-secondary {
    border-color: hsl(var(--border) / 0.8);
    background: hsl(var(--card));
    color: hsl(var(--foreground));
}

.button-secondary:hover {
    background: hsl(var(--muted) / 0.7);
}

.button-danger {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.button-danger:hover {
    background: hsl(var(--destructive) / 0.9);
}

.button-ghost {
    background: transparent;
    color: hsl(var(--muted-foreground));
}

.button-ghost:hover {
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.badge-primary {
    background: hsl(var(--violet-soft));
    color: hsl(var(--violet));
}

.badge-success {
    background: hsl(var(--success-soft));
    color: hsl(var(--success));
}

.badge-warning {
    background: hsl(var(--warning-soft));
    color: hsl(var(--warning));
}

.badge-danger {
    background: hsl(var(--rose-soft));
    color: hsl(var(--destructive));
}

.flash,
.content-alert {
    padding: 0.95rem 1rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
}

.flash-warning,
.content-alert.warning {
    background: hsl(var(--warning-soft));
    border-color: hsl(var(--warning) / 0.35);
}

.app-shell {
    display: flex;
    min-height: 100vh;
    background: hsl(var(--background));
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 70;
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 80;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid hsl(var(--border) / 0.65);
    background: hsl(var(--background) / 0.94);
    backdrop-filter: blur(18px);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border) / 0.6);
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.sidebar-brand h1 {
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.sidebar-logo {
    width: 2.8rem;
    height: 2.8rem;
    object-fit: contain;
    border-radius: calc(var(--radius) + 0.1rem);
}

.sidebar-logo-fallback {
    display: grid;
    place-items: center;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.sidebar-close,
.sidebar-toggle {
    display: none;
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
    color: hsl(var(--foreground));
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.9rem;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.3rem;
    padding: 0.8rem 0.95rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: hsl(var(--muted-foreground));
    font-size: 0.92rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: hsl(var(--muted) / 0.72);
    color: hsl(var(--foreground));
}

.nav-link.active {
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    border-color: hsl(var(--border) / 0.7);
    box-shadow: var(--shadow-card);
}

.nav-icon-wrap {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: calc(var(--radius) - 0.03rem);
    background: hsl(var(--muted));
}

.nav-link.active .nav-icon-wrap {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.sidebar-footer {
    display: grid;
    gap: 0.35rem;
    padding: 1rem 1.15rem;
    border-top: 1px solid hsl(var(--border) / 0.6);
}

.main-shell {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4rem;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid hsl(var(--border) / 0.6);
    background: hsl(var(--background) / 0.88);
    backdrop-filter: blur(16px);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.topbar-title-group {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.topbar h2 {
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.36rem 0.36rem 0.36rem 0.72rem;
    border: 1px solid hsl(var(--border) / 0.7);
    border-radius: 999px;
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    box-shadow: var(--shadow-card);
}

.theme-switch-thumb {
    display: inline-grid;
    place-items: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 999px;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.42rem 0.6rem 0.42rem 0.42rem;
    border: 1px solid hsl(var(--border) / 0.7);
    border-radius: 999px;
    background: hsl(var(--card));
    box-shadow: var(--shadow-card);
    cursor: pointer;
}

.user-copy {
    display: grid;
    min-width: 0;
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    background: hsl(var(--muted));
    font-weight: 700;
}

.user-chip-name {
    font-size: 0.88rem;
    font-weight: 600;
}

.user-chip-role {
    font-size: 0.74rem;
    color: hsl(var(--muted-foreground));
}

.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.75rem);
    width: 14rem;
    z-index: 20;
    display: none;
    padding: 0.7rem;
    border: 1px solid hsl(var(--border) / 0.8);
    border-radius: calc(var(--radius) + 0.05rem);
    background: hsl(var(--popover));
    box-shadow: var(--shadow-soft);
}

.user-menu-dropdown form {
    margin: 0;
}

.user-menu[open] .user-menu-dropdown {
    display: grid;
    gap: 0.35rem;
}

.user-menu-heading {
    display: grid;
    gap: 0.1rem;
    padding: 0.2rem 0.3rem 0.55rem;
    border-bottom: 1px solid hsl(var(--border) / 0.7);
}

.user-menu-name {
    font-size: 0.9rem;
    font-weight: 700;
}

.user-menu-item {
    width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: hsl(var(--foreground));
    text-align: left;
}

.user-menu-item:hover {
    background: hsl(var(--muted));
}

.user-menu-item.danger {
    color: hsl(var(--destructive));
}

.content-shell {
    position: relative;
    flex: 1;
    padding: 1.2rem 1.2rem 1.8rem;
}

.toast-stack {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 120;
    width: min(100%, 24rem);
    display: grid;
    gap: 0.75rem;
}

.auth-toast-stack {
    position: fixed;
}

.toast-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
    align-items: start;
    padding: 0.9rem 1rem;
    border: 1px solid hsl(var(--border) / 0.8);
    border-radius: calc(var(--radius) + 0.05rem);
    background: hsl(var(--card) / 0.97);
    box-shadow: var(--shadow-soft);
}

.toast-success {
    border-color: hsl(var(--success) / 0.3);
}

.toast-warning {
    border-color: hsl(var(--warning) / 0.38);
}

.toast-error {
    border-color: hsl(var(--destructive) / 0.38);
}

.toast-icon {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: hsl(var(--muted));
}

.toast-success .toast-icon {
    background: hsl(var(--success-soft));
    color: hsl(var(--success));
}

.toast-warning .toast-icon {
    background: hsl(var(--warning-soft));
    color: hsl(var(--warning));
}

.toast-error .toast-icon {
    background: hsl(var(--rose-soft));
    color: hsl(var(--destructive));
}

.toast-copy {
    display: grid;
    gap: 0.2rem;
}

.toast-message {
    line-height: 1.5;
}

.toast-close {
    width: 1.9rem;
    height: 1.9rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: hsl(var(--muted-foreground));
}

.toast-close:hover {
    background: hsl(var(--muted));
}

.page,
.grid {
    display: grid;
    gap: 1rem;
}

.page-header,
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-heading {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.page-icon {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: calc(var(--radius) + 0.15rem);
    background: hsl(var(--muted));
}

.page-icon .icon {
    width: 1.35rem;
    height: 1.35rem;
}

.page-copy {
    display: grid;
    gap: 0.25rem;
}

.page-title {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 900;
    letter-spacing: -0.05em;
}

.summary-grid,
.stat-grid,
.page-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
}

.summary-card,
.stat-card,
.mini-card,
.panel {
    border: 1px solid hsl(var(--border) / 0.8);
    border-radius: calc(var(--radius) + 0.05rem);
    background: hsl(var(--card));
    box-shadow: var(--shadow-card);
}

.summary-card,
.stat-card,
.mini-card {
    padding: 1rem;
}

.summary-card {
    grid-column: span 3;
    display: grid;
    gap: 0.8rem;
    min-height: 9.2rem;
}

.summary-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.summary-card-icon {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: calc(var(--radius) + 0.05rem);
    background: hsl(var(--muted));
}

.summary-card-value,
.stat-value {
    font-size: clamp(1.3rem, 3vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    overflow-wrap: anywhere;
}

.summary-card-meta,
.stat-muted {
    font-size: 0.84rem;
}

.summary-card.success {
    background: hsl(var(--success-soft));
    border-color: hsl(var(--success) / 0.22);
}

.summary-card.success .summary-card-icon,
.stat-card.success .summary-card-icon {
    background: hsl(var(--card));
    color: hsl(var(--success));
}

.summary-card.danger {
    background: hsl(var(--rose-soft));
    border-color: hsl(var(--destructive) / 0.22);
}

.summary-card.danger .summary-card-icon {
    background: hsl(var(--card));
    color: hsl(var(--destructive));
}

.summary-card.info {
    background: hsl(var(--info-soft));
    border-color: hsl(var(--info) / 0.22);
}

.summary-card.info .summary-card-icon {
    background: hsl(var(--card));
    color: hsl(var(--info));
}

.summary-card.warning {
    background: hsl(var(--warning-soft));
    border-color: hsl(var(--warning) / 0.22);
}

.summary-card.warning .summary-card-icon {
    background: hsl(var(--card));
    color: hsl(var(--warning));
}

.summary-card.violet {
    background: hsl(var(--violet-soft));
    border-color: hsl(var(--violet) / 0.22);
}

.summary-card.violet .summary-card-icon {
    background: hsl(var(--card));
    color: hsl(var(--violet));
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.mini-card {
    display: grid;
    gap: 0.35rem;
}

.mini-card-value {
    font-size: 1.05rem;
    font-weight: 800;
}

.panel {
    padding: 1.05rem;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.panel-title {
    font-size: 1.04rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.panel-head p,
.panel-subtitle {
    margin-top: 0.3rem;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(18rem, 0.95fr);
    gap: 1rem;
    align-items: start;
}

.page-grid > * {
    grid-column: span 6;
}

.danger-zone {
    border-color: hsl(var(--destructive) / 0.28);
    background: hsl(var(--rose-soft));
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 0.95rem 0.85rem;
    border-bottom: 1px solid hsl(var(--border) / 0.7);
    vertical-align: top;
    text-align: left;
}

thead th {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--muted) / 0.45);
}

.table-sort-button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
}

.table-sort-button.active {
    color: hsl(var(--foreground));
}

.table-sort-indicator {
    min-width: 0.75rem;
    text-align: right;
    font-size: 0.75rem;
}

tbody tr:hover {
    background: hsl(var(--muted) / 0.32);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.list {
    display: grid;
    gap: 0.7rem;
    margin: 0;
    padding-left: 1.2rem;
}

.empty-state {
    padding: 1rem;
    text-align: center;
    color: hsl(var(--muted-foreground));
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: 1rem;
}

.table-footer-group {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.table-footer-label,
.pagination-info {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
}

.page-size-group,
.pagination-group {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.page-size-button {
    min-width: 2.35rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    font-weight: 600;
}

.page-size-button.active {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}

.chart-shell {
    display: grid;
    gap: 1rem;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.84rem;
    color: hsl(var(--muted-foreground));
}

.legend-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 999px;
}

.legend-dot.success {
    background: #10b981;
}

.legend-dot.danger {
    background: #f43f5e;
}

.chart-svg {
    width: 100%;
    min-height: 17rem;
    border: 1px solid hsl(var(--border) / 0.7);
    border-radius: calc(var(--radius) + 0.05rem);
    background:
        linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), hsl(var(--border) / 0.45) calc(25% - 1px), hsl(var(--border) / 0.45) 25%, transparent 25%, transparent calc(50% - 1px), hsl(var(--border) / 0.45) calc(50% - 1px), hsl(var(--border) / 0.45) 50%, transparent 50%, transparent calc(75% - 1px), hsl(var(--border) / 0.45) calc(75% - 1px), hsl(var(--border) / 0.45) 75%, transparent 75%);
    overflow: hidden;
}

.chart-empty {
    min-height: 17rem;
    display: grid;
    place-items: center;
    color: hsl(var(--muted-foreground));
}

.recent-list {
    display: grid;
    gap: 0.7rem;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid hsl(var(--border) / 0.45);
}

.recent-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.recent-value {
    font-size: 0.93rem;
    font-weight: 700;
}

.recent-value.success {
    color: #059669;
}

.recent-value.danger {
    color: #e11d48;
}

.recent-badge {
    margin-top: 0.35rem;
}

.dialog-shell {
    display: grid;
    gap: 1rem;
}

.dialog-card {
    position: sticky;
    top: 5.2rem;
}

.dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.dialog-close {
    width: 2.2rem;
    height: 2.2rem;
    display: grid;
    place-items: center;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
}

.modal-shell {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.modal-shell[hidden] {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(2px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 44rem);
    max-height: calc(100vh - 2.5rem);
    overflow: auto;
    padding: 1.35rem;
    border: 1px solid hsl(var(--border) / 0.85);
    border-radius: calc(var(--radius) + 0.2rem);
    background: hsl(var(--card));
    box-shadow: var(--shadow-soft);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-close {
    width: 2.35rem;
    height: 2.35rem;
    display: grid;
    place-items: center;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
}

body.modal-open {
    overflow: hidden;
}

.toolbar-card {
    display: grid;
    gap: 1rem;
}

.toolbar-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 0.85rem;
    align-items: end;
}

.toolbar-grid .field-span-3 {
    grid-column: span 3;
}

.toolbar-grid .field-span-2 {
    grid-column: span 2;
}

.toolbar-grid .field-span-4 {
    grid-column: span 4;
}

.toolbar-grid .field-span-6 {
    grid-column: span 6;
}

.toolbar-grid .field-span-12 {
    grid-column: span 12;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.preview-card {
    display: grid;
    gap: 0.75rem;
}

.preview-logo {
    width: 4.5rem;
    height: 4.5rem;
    display: grid;
    place-items: center;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 0.15rem);
    background: hsl(var(--muted));
}

.preview-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.table-note {
    margin-top: 0.65rem;
    font-size: 0.84rem;
    color: hsl(var(--muted-foreground));
}

.page-note {
    padding: 0.95rem 1rem;
    border: 1px dashed hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--muted) / 0.32);
    color: hsl(var(--muted-foreground));
}

@media (max-width: 1280px) {
    .summary-card {
        grid-column: span 6;
    }

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

@media (max-width: 1024px) {
    .split-layout,
    .page-grid {
        grid-template-columns: 1fr;
    }

    .page-grid > * {
        grid-column: auto;
    }

    .dialog-card {
        position: static;
    }

    .modal-card {
        width: min(100%, 100%);
    }
}

@media (max-width: 960px) {
    .sidebar-toggle,
    .sidebar-close {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.24s ease;
        box-shadow: var(--shadow-soft);
    }

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

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

    .content-shell,
    .topbar {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .topbar h2 {
        font-size: 0.95rem;
    }

    .theme-switch span:not(.theme-switch-thumb) {
        display: none;
    }

    .user-copy {
        display: none;
    }

    .toast-stack {
        left: 1rem;
        right: 1rem;
        width: auto;
    }
}

@media (max-width: 768px) {
    .login-card {
        padding: 1.4rem;
    }

    .summary-card,
    .mini-card {
        grid-column: span 12;
    }

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

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

    .toolbar-grid .field-span-2,
    .toolbar-grid .field-span-3,
    .toolbar-grid .field-span-4,
    .toolbar-grid .field-span-6,
    .toolbar-grid .field-span-12 {
        grid-column: auto;
    }

    .table-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .table-footer-group {
        justify-content: space-between;
    }

    .page-heading {
        align-items: flex-start;
    }

    .page-icon {
        width: 2.7rem;
        height: 2.7rem;
    }

    th,
    td {
        padding: 0.8rem 0.65rem;
    }
}
