@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --white: #ffffff;
    --gray-25: #0f1520;
    --gray-50: #151c29;
    --gray-100: #1d2635;
    --gray-200: #2a3548;
    --gray-300: #3a4860;
    --gray-400: #71809b;
    --gray-500: #8e9cb2;
    --gray-600: #adb9cc;
    --gray-700: #c8d1e0;
    --gray-800: #dde4ef;
    --gray-900: #eef3fb;

    --brand-25: #19233b;
    --brand-50: #1f2d4a;
    --brand-100: #28406f;
    --brand-200: #9eb8ff;
    --brand-400: #5a84ff;
    --brand-500: #3f72ff;
    --brand-600: #2f62ea;
    --brand-700: #244fbe;

    --green-50: #132720;
    --green-100: #1a3b2f;
    --green-500: #219a5f;
    --green-700: #1b7249;

    --red-50: #2e1a1a;
    --red-100: #452323;
    --red-500: #dc4f43;
    --red-700: #a8382f;

    --yellow-50: #2f2618;
    --yellow-100: #4a3a21;
    --yellow-500: #d79a35;
    --yellow-700: #a06f21;

    --blue-50: #172637;
    --blue-100: #223a57;
    --blue-500: #2d7fd0;
    --blue-700: #1d5c99;

    --sidebar-w: 252px;
    --topbar-h: 66px;
    --radius-sm: 7px;
    --radius: 10px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 3px 10px rgba(0, 0, 0, 0.32);
    --shadow-md: 0 10px 24px rgba(0, 0, 0, 0.36);
    --shadow-lg: 0 18px 36px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 26px 52px rgba(0, 0, 0, 0.45);
    --ring-brand: 0 0 0 4px rgba(63, 114, 255, 0.18), 0 0 0 1px var(--brand-500);

    --font: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

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

html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: var(--font);
    background: linear-gradient(180deg, #0d131d 0%, #111a27 45%, #0d141f 100%);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
}

::selection { background: var(--brand-500); color: #fff; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }

a { color: var(--brand-600); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--brand-700); }

hr { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--brand-700);
}

/* =========================================================
   APP SHELL
   ========================================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #121b2a 0%, #101826 100%);
    border-right: 1px solid rgba(255,255,255,.06);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
}

.sidebar-head {
    height: var(--topbar-h);
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-logo-img {
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.01em;
}

.sidebar-body {
    flex: 1;
    padding: 16px 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-section {
    padding-top: 16px;
}
.sidebar-section:first-child { padding-top: 0; }

.sidebar-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
    padding: 0 8px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--gray-500);
    font-size: 0.86rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.15s;
    position: relative;
    text-decoration: none;
}
.sidebar-link span { flex: 1; }
.sidebar-link:hover {
    background: rgba(255,255,255,.03);
    border-color: rgba(255,255,255,.06);
    color: var(--gray-900);
}
.sidebar-link.active {
    background: rgba(63,114,255,.06);
    border-color: rgba(63,114,255,.12);
    color: #60a5fa;
    font-weight: 600;
}
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-500);
}
.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 1.8;
}
.sidebar-link .link-badge {
    margin-left: auto;
    background: #f43f5e;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    line-height: 1.4;
}
.sidebar-link .link-badge-blue {
    background: rgba(63,114,255,.15);
    color: #60a5fa;
}

.sidebar-foot {
    padding: 12px 8px;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s;
    color: inherit;
}
.sidebar-profile:hover { background: rgba(255,255,255,.04); color: inherit; }

.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.72rem;
    flex-shrink: 0;
    background: var(--brand-50);
    color: var(--brand-700);
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }

.profile-text { flex: 1; min-width: 0; }
.profile-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-sub {
    font-size: 0.7rem;
    color: var(--gray-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================================
   MAIN
   ========================================================= */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: rgba(19, 28, 42, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}
.breadcrumb-item { color: var(--gray-400); font-weight: 500; }
.breadcrumb-item a { color: var(--gray-400); }
.breadcrumb-item a:hover { color: var(--gray-600); }
.breadcrumb-sep { color: var(--gray-300); font-size: 0.75rem; display:flex;align-items:center; }
.breadcrumb-current { color: var(--gray-900); font-weight: 600; }

.mobile-btn {
    display: none;
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    cursor: pointer;
    padding: 6px;
    transition: background 0.12s;
}
.mobile-btn:hover { background: var(--gray-100); }
.mobile-btn svg { width: 18px; height: 18px; display: block; }

.page-wrap {
    padding: 32px;
    max-width: 1320px;
    flex: 1;
}

/* =========================================================
   PAGE HEADER
   ========================================================= */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-head h1 {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
    line-height: 1.3;
}
.page-head p {
    color: var(--gray-500);
    margin-top: 2px;
    font-size: 0.88rem;
}
.page-head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* =========================================================
   CARDS
   ========================================================= */
.card {
    background: linear-gradient(180deg, #162131 0%, #131d2d 100%);
    border: 1px solid #2b374b;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #2e3a4f;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h2, .card-header h3 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--gray-900);
}

.card-body { padding: 20px; }
.card-body-flush { padding: 0; }

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid #2e3a4f;
    background: #121c2c;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* =========================================================
   METRICS / STATS
   ========================================================= */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.metric {
    background: linear-gradient(180deg, #172232 0%, #131e2f 100%);
    border: 1px solid #2a364a;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: box-shadow 0.15s, transform 0.15s;
}
.metric:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.metric-icon svg { width: 20px; height: 20px; }
.metric-icon.purple { background: var(--brand-50); color: var(--brand-600); }
.metric-icon.green { background: var(--green-50); color: var(--green-500); }
.metric-icon.orange { background: var(--yellow-50); color: var(--yellow-500); }
.metric-icon.red { background: var(--red-50); color: var(--red-500); }
.metric-icon.blue { background: var(--blue-50); color: var(--blue-500); }

.metric-value {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--gray-900);
}
.metric-label {
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-top: 2px;
    font-weight: 500;
}

/* =========================================================
   TABLES
   ========================================================= */
.table-wrap { overflow-x: auto; }

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

th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-500);
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid #334158;
    background: #121c2c;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid #273245;
    color: var(--gray-600);
    vertical-align: middle;
}
td a { font-weight: 600; }

tr:last-child td { border-bottom: none; }
tr:hover td { background: #1a2637; }

tfoot td {
    border-bottom: none;
    background: transparent;
    font-weight: 600;
    color: var(--gray-700);
}

/* =========================================================
   BADGES
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge-success { background: var(--green-50); color: var(--green-700); }
.badge-success::before { background: var(--green-500); }
.badge-warning { background: var(--yellow-50); color: var(--yellow-700); }
.badge-warning::before { background: var(--yellow-500); }
.badge-danger { background: var(--red-50); color: var(--red-700); }
.badge-danger::before { background: var(--red-500); }
.badge-primary { background: var(--brand-25); color: var(--brand-700); }
.badge-primary::before { background: var(--brand-500); }
.badge-info { background: var(--blue-50); color: var(--blue-700); }
.badge-info::before { background: var(--blue-500); }
.badge-secondary { background: var(--gray-100); color: var(--gray-600); }
.badge-secondary::before { background: var(--gray-400); }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.25;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
    color: #fff;
    box-shadow: 0px 1px 2px rgba(16,24,40,0.05);
}
.btn-primary:hover {
    background: linear-gradient(145deg, var(--brand-600), #1f43a8);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: #1a2637;
    color: var(--gray-700);
    border-color: var(--gray-300);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
    background: #233248;
    color: var(--gray-900);
}

.btn-danger {
    background: var(--white);
    color: var(--red-700);
    border-color: var(--red-100);
}
.btn-danger:hover {
    background: var(--red-50);
    border-color: var(--red-500);
}

.btn-warning {
    background: var(--yellow-500);
    color: #fff;
    border-color: var(--yellow-500);
}
.btn-warning:hover {
    background: var(--yellow-700);
    border-color: var(--yellow-700);
    color: #fff;
}

.btn-success {
    background: var(--green-500);
    color: #fff;
    box-shadow: 0px 1px 2px rgba(16,24,40,0.05);
}
.btn-success:hover {
    background: var(--green-700);
    color: #fff;
}

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 11px 20px; font-size: 0.92rem; }
.btn-block { width: 100%; }

.btn-icon {
    padding: 8px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    color: var(--gray-500);
    box-shadow: var(--shadow-xs);
}
.btn-icon:hover { background: var(--gray-50); color: var(--gray-900); }

/* =========================================================
   FORMS
   ========================================================= */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control,
.form-input {
    width: 100%;
    padding: 9px 14px;
    background: #121c2b;
    border: 1px solid #304057;
    border-radius: var(--radius);
    color: var(--gray-900);
    font-family: inherit;
    font-size: 0.88rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), var(--shadow-xs);
}
.form-control:focus,
.form-input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: var(--ring-brand);
}
.form-control::placeholder,
.form-input::placeholder { color: var(--gray-400); }

textarea.form-control,
textarea.form-input { resize: vertical; min-height: 100px; }

select.form-control,
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23667085' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint { font-size: 0.78rem; color: var(--gray-500); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--red-500); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--gray-700);
}
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-500);
}

/* =========================================================
   ALERTS
   ========================================================= */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    margin-bottom: 20px;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.25s ease-out;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: var(--green-50); color: var(--green-700); border-color: var(--green-100); }
.alert-danger { background: var(--red-50); color: var(--red-700); border-color: var(--red-100); }
.alert-warning { background: var(--yellow-50); color: var(--yellow-700); border-color: var(--yellow-100); }
.alert-info { background: var(--blue-50); color: var(--blue-700); border-color: var(--blue-100); }

/* =========================================================
   PAGINATION
   ========================================================= */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
}
.pagination-link {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
    font-size: 0.82rem;
    font-weight: 500;
    background: var(--white);
    transition: all 0.12s;
}
.pagination-link:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}
.pagination-link.active {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}

/* =========================================================
   TICKET CHAT
   ========================================================= */
.ticket-chat {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}
.chat-message {
    display: flex;
    gap: 12px;
    max-width: 75%;
}
.chat-message.staff {
    flex-direction: row-reverse;
    margin-left: auto;
}
.chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.7rem;
    flex-shrink: 0;
}
.chat-message:not(.staff) .chat-avatar { background: var(--brand-50); color: var(--brand-700); }
.chat-message.staff .chat-avatar { background: var(--green-50); color: var(--green-700); }

.chat-bubble {
    background: #1a2536;
    border: 1px solid #2f3d54;
    border-radius: var(--radius-lg);
    padding: 12px 16px;
}
.chat-message.staff .chat-bubble {
    background: #1d2e4b;
    border-color: #36527d;
}
.chat-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.chat-meta .name { font-weight: 600; font-size: 0.82rem; color: var(--gray-900); }
.chat-meta .time { font-size: 0.72rem; color: var(--gray-400); }
.chat-text { font-size: 0.88rem; line-height: 1.65; white-space: pre-wrap; word-break: break-word; color: var(--gray-600); }

/* =========================================================
   EMPTY STATE
   ========================================================= */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state svg { width: 40px; height: 40px; color: var(--gray-400); margin-bottom: 12px; }
.empty-state h3 { font-size: 0.95rem; color: var(--gray-700); margin-bottom: 4px; font-weight: 600; }
.empty-state p { color: var(--gray-500); margin-bottom: 16px; font-size: 0.85rem; }

/* =========================================================
   FILTERS
   ========================================================= */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-bar .form-control {
    width: auto;
    min-width: 150px;
    padding: 7px 12px;
    font-size: 0.82rem;
}

/* =========================================================
   DETAIL GRID
   ========================================================= */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}
.detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    margin-bottom: 4px;
}
.detail-value {
    font-size: 0.95rem;
    color: var(--gray-900);
    font-weight: 600;
}

/* =========================================================
   GRID LAYOUTS
   ========================================================= */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* =========================================================
   UTILITY
   ========================================================= */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-danger { color: var(--red-500); }
.text-success { color: var(--green-500); }
.font-mono { font-family: var(--mono); }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.px-2 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 16px; padding-bottom: 16px; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inline-flex { display: inline-flex; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.text-xs { font-size: 0.72rem; }
.text-sm { font-size: 0.82rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.35rem; }
.text-brand { color: var(--brand-500); }
.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }
.tabular-nums { font-variant-numeric: tabular-nums; }

.divider { border-top: 1px solid var(--gray-200); margin: 20px 0; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 16, 0.58);
    backdrop-filter: blur(4px);
    z-index: 99;
}

/* .page-header aliased to .page-head for backward compat (admin) */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-header h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--gray-900);
    line-height: 1.3;
}
.page-header p { color: var(--gray-500); margin-top: 2px; font-size: 0.88rem; }
.table-container, .table-wrap { overflow-x: auto; }

/* stat cards (used by admin, gameserver) */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: linear-gradient(180deg, #172232 0%, #131e2f 100%); border: 1px solid #2a364a; border-radius: var(--radius-lg); padding: 20px; display: flex; align-items: flex-start; gap: 14px; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s, transform 0.15s; }
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon { width: 40px; height: 40px; border-radius: var(--radius); display: grid; place-items: center; flex-shrink: 0; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.blue { background: var(--brand-50); color: var(--brand-600); }
.stat-icon.green { background: var(--green-50); color: var(--green-500); }
.stat-icon.yellow { background: var(--yellow-50); color: var(--yellow-500); }
.stat-icon.red { background: var(--red-50); color: var(--red-500); }
.stat-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; color: var(--gray-900); }
.stat-label { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; font-weight: 500; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main { margin-left: 0; }
    .mobile-btn { display: block; }
    .page-wrap { padding: 20px 16px; }
    .topbar { padding: 0 16px; }
    .form-row { grid-template-columns: 1fr; }
    .grid-2, .grid-2-1, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .metrics, .stats-grid { grid-template-columns: 1fr 1fr; }
    .chat-message { max-width: 95%; }
}

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

/* =========================================================
   GLOBAL CONFIRM MODAL
   ========================================================= */
.kh-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, visibility .2s;
}
.kh-confirm-overlay.kh-confirm-open {
    opacity: 1;
    visibility: visible;
}
.kh-confirm-box {
    background: linear-gradient(180deg, #1c2a3e 0%, #151e2d 100%);
    border: 1px solid #2a374c;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    margin: 16px;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .03);
    transform: scale(.92) translateY(10px);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}
.kh-confirm-open .kh-confirm-box {
    transform: scale(1) translateY(0);
}
.kh-confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
}
.kh-confirm-icon svg {
    width: 24px;
    height: 24px;
}
.kh-confirm-icon--danger {
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .2);
    color: #ef4444;
}
.kh-confirm-icon--warning {
    background: rgba(245, 158, 11, .1);
    border: 1px solid rgba(245, 158, 11, .2);
    color: #f59e0b;
}
.kh-confirm-icon--info {
    background: rgba(59, 130, 246, .1);
    border: 1px solid rgba(59, 130, 246, .2);
    color: #3b82f6;
}
.kh-confirm-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 6px;
}
.kh-confirm-desc {
    font-size: .82rem;
    color: #94a3b8;
    line-height: 1.5;
    margin-bottom: 24px;
    padding: 0 8px;
    word-break: break-word;
}
.kh-confirm-actions {
    display: flex;
    gap: 10px;
}
.kh-confirm-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: .84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.kh-confirm-btn svg {
    width: 15px;
    height: 15px;
}
.kh-confirm-cancel {
    background: rgba(255, 255, 255, .05);
    border: 1px solid #2a374c;
    color: #94a3b8;
}
.kh-confirm-cancel:hover {
    background: rgba(255, 255, 255, .08);
    color: #e2e8f0;
    border-color: #38547d;
}
.kh-confirm-ok--danger {
    background: rgba(239, 68, 68, .15);
    border: 1px solid rgba(239, 68, 68, .3);
    color: #ef4444;
}
.kh-confirm-ok--danger:hover {
    background: rgba(239, 68, 68, .25);
    border-color: rgba(239, 68, 68, .5);
    color: #fca5a5;
}
.kh-confirm-ok--warning {
    background: rgba(245, 158, 11, .15);
    border: 1px solid rgba(245, 158, 11, .3);
    color: #f59e0b;
}
.kh-confirm-ok--warning:hover {
    background: rgba(245, 158, 11, .25);
    border-color: rgba(245, 158, 11, .5);
    color: #fde68a;
}
.kh-confirm-ok--info {
    background: rgba(59, 130, 246, .15);
    border: 1px solid rgba(59, 130, 246, .3);
    color: #3b82f6;
}
.kh-confirm-ok--info:hover {
    background: rgba(59, 130, 246, .25);
    border-color: rgba(59, 130, 246, .5);
    color: #93c5fd;
}

/* --- Copy Feedback --- */
.kh-copied {
    color: #4ade80 !important;
    pointer-events: none;
    transition: color .15s;
}
.kh-copied svg { stroke: #4ade80; }
.kh-copy-label {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
}
