/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */
:root {
    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Brand */
    --emerald-50: #dafec7;
    --emerald-100: #a2fd4c;
    --emerald-200: #90e53f;
    --emerald-400: #6daf2e;
    --emerald-500: #5e9826;
    --emerald-600: #4e7f1e;
    --emerald-700: #3e6617;
    --emerald-800: #305110;
    --emerald-900: #172b05;
    --gold-400: #e8ac1c;

    /* Neutral */
    --neutral-50: #f0f2f4;
    --neutral-100: #e1e5ea;
    --neutral-200: #c3cbd5;
    --neutral-300: #a3aebd;
    --neutral-400: #8594a8;
    --neutral-500: #687a92;
    --neutral-600: #536174;
    --neutral-700: #3e4856;
    --neutral-800: #2a323c;
    --neutral-900: #15191e;

    /* Semantic */
    --amber-50: #fffbeb;
    --amber-100: #fef3c7;
    --amber-200: #fde68a;
    --amber-400: #fbbf24;
    --amber-500: #f59e0b;
    --amber-600: #d97706;
    --amber-700: #b45309;

    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-200: #fecaca;
    --red-400: #f87171;
    --red-500: #ef4444;
    --red-600: #dc2626;

    --blue-50: #eff6ff;
    --blue-200: #bfdbfe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;

    --purple-50: #faf5ff;
    --purple-200: #e9d5ff;
    --purple-500: #a855f7;
    --purple-600: #9333ea;

    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;

    --bg-page: #E6E6E6;
    --sidebar-w: 256px;
    --titlebar-h: 32px;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--neutral-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
    border: none;
    background: none;
}

button { cursor: pointer; }

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

img, svg {
    display: block;
    max-width: 100%;
}

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

ol, ul { list-style: none; }

/* ============================================
   TITLE BAR
   ============================================ */
.titlebar {
    height: var(--titlebar-h);
    background: var(--emerald-800);
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    user-select: none;
    -webkit-app-region: drag;
}

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

.titlebar__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold-400);
}

.titlebar__text {
    color: var(--gold-400);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* ============================================
   LAYOUT WRAPPER
   ============================================ */
.app-wrapper {
    min-height: 100vh;
    padding-top: var(--titlebar-h);
    display: flex;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--emerald-800);
    border-right: 1px solid #1a2d09;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--titlebar-h));
    position: fixed;
    top: var(--titlebar-h);
    left: 0;
    z-index: 50;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.sidebar__logo-box {
    padding: 16px;
}

.sidebar__logo-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 24px;
    border-radius: 16px;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
}

.sidebar__logo-inner img {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.sidebar__nav {
    flex: 1;
    padding: 0 16px;
    margin-top: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    transition: all 0.2s;
    color: #E6E6E6;
    border: 1px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-link--active {
    background: var(--gold-400);
    color: var(--emerald-800);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(232,172,28,0.3);
}

.nav-link--active:hover {
    background: var(--gold-400);
    color: var(--emerald-800);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-link--active svg {
    color: var(--emerald-800);
}

/* ============================================
   MAIN AREA
   ============================================ */
.main-area {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--titlebar-h));
    transition: margin-left 0.3s;
    overflow-x: hidden;
}

/* ============================================
   TOP HEADER
   ============================================ */
.top-header {
    height: 64px;
    background: var(--bg-page);
    border-bottom: 1px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 32px;
    position: sticky;
    top: var(--titlebar-h);
    z-index: 40;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.top-header__right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px;
    border-radius: 12px;
}

.profile-badge__avatar {
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-300);
    color: var(--emerald-800);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.875rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.profile-badge__info {
    font-size: 0.875rem;
}

.profile-badge__name {
    font-weight: 700;
    color: var(--emerald-800);
}

.profile-badge__label {
    font-size: 10px;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
}

.divider-v {
    width: 1px;
    height: 24px;
    background: var(--gray-300);
}

.btn-switch {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--gold-400);
    background: var(--emerald-800);
    padding: 8px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-switch:hover {
    background: var(--gold-400);
    color: var(--emerald-800);
}

.btn-switch svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.btn-switch:hover svg {
    transform: translateX(4px);
}

/* Hamburger for mobile */
.btn-hamburger {
    display: none;
    color: var(--gray-500);
    padding: 8px;
    border-radius: 12px;
    transition: all 0.2s;
}

.btn-hamburger:hover {
    background: var(--gray-200);
    color: var(--neutral-900);
}

.btn-hamburger svg {
    width: 24px;
    height: 24px;
}

/* ============================================
   CONTENT
   ============================================ */
.content {
    flex: 1;
    padding: 32px;
    overflow-x: hidden;
    min-width: 0;
    width: 100%;
}

.page-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 48px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--neutral-900);
    line-height: 1.2;
}

.page-subtitle {
    color: var(--neutral-500);
    margin-top: 4px;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.card {
    background: #fff;
    border: 1px solid var(--neutral-200);
    border-radius: 24px;
    padding: 24px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge--success { background: rgba(94,152,38,0.1); color: var(--emerald-600); }
.badge--warning { background: rgba(245,158,11,0.1); color: var(--amber-600); }
.badge--danger { background: rgba(239,68,68,0.1); color: var(--red-600); }
.badge--neutral { background: var(--neutral-100); color: var(--neutral-600); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.btn--primary {
    background: var(--emerald-500);
    color: #fff;
    box-shadow: 0 4px 12px rgba(94,152,38,0.3);
}
.btn--primary:hover {
    background: var(--emerald-600);
}
.btn--secondary {
    background: #fff;
    color: var(--neutral-700);
    border-color: var(--neutral-200);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn--secondary:hover {
    background: var(--neutral-50);
    border-color: var(--neutral-300);
}
.btn--danger {
    background: #fff;
    color: var(--red-500);
    border-color: rgba(239,68,68,0.3);
}
.btn--danger:hover {
    background: rgba(239,68,68,0.1);
}

.input {
    width: 100%;
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 0.875rem;
    color: var(--neutral-800);
    transition: all 0.2s;
    outline: none;
}
.input:focus {
    border-color: var(--emerald-500);
    box-shadow: 0 0 0 2px rgba(94,152,38,0.2);
    background: #fff;
}
.input-group {
    margin-bottom: 16px;
}
.input-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--neutral-500);
    margin-bottom: 8px;
}

/* ============================================
   TABLE STYLES
   ============================================ */
.table-wrap {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    min-width: 800px;
    text-align: left;
    font-size: 0.875rem;
    white-space: nowrap;
}

.data-table thead tr {
    border-bottom: 1px solid var(--neutral-200);
    background: rgba(240,242,244,0.5);
}

.data-table th {
    padding: 16px;
    font-weight: 600;
    color: var(--neutral-600);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--neutral-100);
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: var(--neutral-50);
}

.data-table td {
    padding: 16px;
}

/* ============================================
   MOBILE OVERLAY
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
}
.sidebar-overlay--visible { display: block; }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.5s ease both; }
.animate-in:nth-child(2) { animation-delay: 100ms; }
.animate-in:nth-child(3) { animation-delay: 200ms; }
.animate-in:nth-child(4) { animation-delay: 300ms; }
.animate-in:nth-child(5) { animation-delay: 400ms; }
.animate-spin { animation: spin 1s linear infinite; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar--open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .btn-hamburger { display: flex; }
    .top-header { justify-content: space-between; padding: 0 16px; }
    .content { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .profile-badge__info { display: none; }
    .btn-switch span { display: none; }
}
