/* ============================================================
   Sibol Design System — 2026 Light Theme
   Primary: #005dcb
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* ── Design tokens ── */
:root {
    /* Brand */
    --blue:         #005dcb;
    --blue-50:      #eff6ff;
    --blue-100:     #dbeafe;
    --blue-200:     #bfdbfe;
    --blue-600:     #005dcb;
    --blue-700:     #004aaa;
    --blue-800:     #003888;

    --green:        #059669;
    --green-50:     #ecfdf5;
    --green-100:    #d1fae5;
    --green-700:    #047857;

    --amber:        #d97706;
    --amber-50:     #fffbeb;
    --amber-100:    #fef3c7;
    --amber-700:    #b45309;

    --red:          #dc2626;
    --red-50:       #fef2f2;
    --red-100:      #fee2e2;
    --red-700:      #b91c1c;

    --purple:       #7c3aed;
    --purple-50:    #f5f3ff;
    --purple-100:   #ede9fe;
    --purple-700:   #6d28d9;

    /* Neutrals */
    --white:        #ffffff;
    --gray-50:      #f9fafb;
    --gray-100:     #f3f4f6;
    --gray-200:     #e5e7eb;
    --gray-300:     #d1d5db;
    --gray-400:     #9ca3af;
    --gray-500:     #6b7280;
    --gray-600:     #4b5563;
    --gray-700:     #374151;
    --gray-800:     #1f2937;
    --gray-900:     #111827;

    /* Semantic surfaces */
    --surface:      var(--white);
    --surface-2:    var(--gray-50);
    --surface-3:    var(--gray-100);
    --bg:           var(--gray-50);

    /* Semantic text */
    --txt:          var(--gray-900);
    --txt-2:        var(--gray-600);
    --txt-3:        var(--gray-400);

    /* Semantic borders */
    --border:       var(--gray-200);
    --border-2:     var(--gray-300);

    /* Radius */
    --r-sm:  4px;
    --r:     8px;
    --r-md:  10px;
    --r-lg:  14px;
    --r-xl:  18px;
    --r-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,.07), 0 4px 6px -4px rgba(0,0,0,.05);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);

    /* Transitions */
    --t:     150ms ease;
    --t-md:  200ms ease;

    /* Sidebar */
    --sidebar-w: 230px;

    /* Z-index scale */
    --z-sticky:  50;
    --z-overlay: 100;
    --z-modal:   200;
    --z-toast:   300;
}

/* ── Base ── */
html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--txt);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ── Typography ── */
.text-xs   { font-size: 11px; line-height: 1.4; }
.text-sm   { font-size: 12px; line-height: 1.5; }
.text-base { font-size: 14px; line-height: 1.5; }
.text-md   { font-size: 15px; line-height: 1.5; }
.text-lg   { font-size: 16px; line-height: 1.4; }
.text-xl   { font-size: 20px; line-height: 1.3; }
.text-2xl  { font-size: 24px; line-height: 1.2; }
.text-3xl  { font-size: 30px; line-height: 1.2; }

.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }

.tracking-wide  { letter-spacing: .025em; }
.tracking-wider { letter-spacing: .05em; }
.uppercase { text-transform: uppercase; }
.capitalize { text-transform: capitalize; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Semantic text colors */
.text-primary   { color: var(--txt); }
.text-secondary { color: var(--txt-2); }
.text-muted     { color: var(--txt-3); }
.text-blue      { color: var(--blue); }
.text-green     { color: var(--green); }
.text-red       { color: var(--red); }
.text-amber     { color: var(--amber); }
.text-purple    { color: var(--purple); }
.text-white     { color: #fff; }

/* ── Layout ── */
.flex         { display: flex; }
.inline-flex  { display: inline-flex; }
.grid         { display: grid; }
.block        { display: block; }
.inline-block { display: inline-block; }
.hidden       { display: none !important; }

.flex-col   { flex-direction: column; }
.flex-row   { flex-direction: row; }
.flex-wrap  { flex-wrap: wrap; }
.flex-1     { flex: 1; }
.flex-none  { flex: none; }
.flex-shrink-0 { flex-shrink: 0; }

.items-start   { align-items: flex-start; }
.items-center  { align-items: center; }
.items-end     { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start   { justify-content: flex-start; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.justify-between { justify-content: space-between; }

.gap-1  { gap: 4px; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.gap-5  { gap: 20px; }
.gap-6  { gap: 24px; }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-w-0 { min-width: 0; }
.min-h-0 { min-height: 0; }
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-auto { overflow-x: auto; }

/* Spacing */
.p-0  { padding: 0; }
.p-2  { padding: 8px; }
.p-3  { padding: 12px; }
.p-4  { padding: 16px; }
.p-5  { padding: 20px; }
.p-6  { padding: 24px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-5 { padding-left: 20px; padding-right: 20px; }
.px-6 { padding-left: 24px; padding-right: 24px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.pt-2 { padding-top: 8px; }
.pt-4 { padding-top: 16px; }
.pb-2 { padding-bottom: 8px; }
.pb-4 { padding-bottom: 16px; }

.m-0     { margin: 0; }
.mx-auto { margin-left: auto; margin-right: auto; }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mb-1    { margin-bottom: 4px; }
.mb-2    { margin-bottom: 8px; }
.mb-3    { margin-bottom: 12px; }
.mb-4    { margin-bottom: 16px; }
.mb-5    { margin-bottom: 20px; }
.mb-6    { margin-bottom: 24px; }
.mt-1    { margin-top: 4px; }
.mt-2    { margin-top: 8px; }
.mt-3    { margin-top: 12px; }
.mt-4    { margin-top: 16px; }
.mt-6    { margin-top: 24px; }

/* Responsive grid helpers */
.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 20px;
    box-shadow: var(--shadow-xs);
}

.card-sm { padding: 14px 16px; }
.card-lg { padding: 24px 28px; }

.card-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--txt);
    letter-spacing: .01em;
}

.card-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px -20px;
}

/* ── Stat cards ── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--t);
}

.stat-card:hover { box-shadow: var(--shadow-sm); }

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--r);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 18px;
}

.stat-icon-blue   { background: var(--blue-50);   color: var(--blue); }
.stat-icon-green  { background: var(--green-50);  color: var(--green); }
.stat-icon-amber  { background: var(--amber-50);  color: var(--amber); }
.stat-icon-purple { background: var(--purple-50); color: var(--purple); }

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--txt-3);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 4px;
}

.stat-val {
    font-size: 24px;
    font-weight: 600;
    color: var(--txt);
    line-height: 1.2;
    letter-spacing: -.02em;
}

.stat-sub {
    font-size: 12px;
    color: var(--txt-3);
    margin-top: 4px;
}

.stat-up   { color: var(--green); font-weight: 500; }
.stat-down { color: var(--red);   font-weight: 500; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--r);
    border: 1px solid var(--border-2);
    background: var(--surface);
    font-size: 13px;
    font-weight: 500;
    color: var(--txt-2);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--t);
    white-space: nowrap;
    line-height: 1;
    box-shadow: var(--shadow-xs);
}

.btn:hover  { background: var(--gray-50); color: var(--txt); border-color: var(--border-2); }
.btn:active { transform: scale(.98); }

.btn-primary {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
    box-shadow: 0 1px 2px rgba(0,93,203,.2);
}
.btn-primary:hover {
    background: var(--blue-700);
    border-color: var(--blue-700);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,93,203,.3);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}
.btn-danger:hover { background: var(--red-700); border-color: var(--red-700); color: #fff; }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--txt-2);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-blue-soft {
    background: var(--blue-50);
    color: var(--blue);
    border-color: var(--blue-100);
}
.btn-blue-soft:hover { background: var(--blue-100); color: var(--blue-700); }

.btn-xs  { padding: 3px 8px;  font-size: 11px; gap: 3px; }
.btn-sm  { padding: 5px 10px; font-size: 12px; gap: 4px; }
.btn-lg  { padding: 10px 20px; font-size: 14px; }
.btn-xl  { padding: 13px 24px; font-size: 15px; font-weight: 600; }
.btn-block { width: 100%; }

.btn:disabled,
.btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn i { font-size: 15px; }
.btn-sm i { font-size: 14px; }
.btn-xs i { font-size: 12px; }

/* ── Forms ── */
.form-group  { margin-bottom: 16px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--txt-2);
    margin-bottom: 6px;
    letter-spacing: .01em;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-2);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--txt);
    font-size: 14px;
    outline: none;
    transition: border-color var(--t), box-shadow var(--t);
    line-height: 1.4;
    box-shadow: var(--shadow-xs);
}

.form-control:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,93,203,.1);
}

.form-control::placeholder { color: var(--txt-3); }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint  { font-size: 11px; color: var(--txt-3); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--red);   margin-top: 4px; }
.invalid-feedback { font-size: 11px; color: var(--red); margin-top: 4px; display: block; }
.is-invalid { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(220,38,38,.1) !important; }

/* Checkbox / Radio */
.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--txt-2);
    user-select: none;
}

.check-label input[type="checkbox"],
.check-label input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--blue);
    cursor: pointer;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 500px;
}

.table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--txt-3);
    padding: 0 16px 10px 0;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.table td {
    padding: 11px 16px 11px 0;
    border-bottom: 1px solid var(--border);
    color: var(--txt-2);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--t); }
.table tbody tr:hover td { background: var(--gray-50); }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--r-full);
    white-space: nowrap;
    letter-spacing: .01em;
}

.badge-blue   { background: var(--blue-50);   color: var(--blue);   border: 1px solid var(--blue-100); }
.badge-green  { background: var(--green-50);  color: var(--green-700);  border: 1px solid var(--green-100); }
.badge-red    { background: var(--red-50);    color: var(--red-700);    border: 1px solid var(--red-100); }
.badge-amber  { background: var(--amber-50);  color: var(--amber-700);  border: 1px solid var(--amber-100); }
.badge-purple { background: var(--purple-50); color: var(--purple-700); border: 1px solid var(--purple-100); }
.badge-gray   { background: var(--gray-100);  color: var(--gray-600);   border: 1px solid var(--gray-200); }

/* Legacy aliases */
.badge-success { background: var(--green-50);  color: var(--green-700);  border: 1px solid var(--green-100); }
.badge-danger  { background: var(--red-50);    color: var(--red-700);    border: 1px solid var(--red-100); }
.badge-warning { background: var(--amber-50);  color: var(--amber-700);  border: 1px solid var(--amber-100); }
.badge-info    { background: var(--blue-50);   color: var(--blue);       border: 1px solid var(--blue-100); }

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--r);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid transparent;
}

.alert i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

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

/* ── Pagination ── */
.pagination {
    display: flex;
    gap: 4px;
    margin-top: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: var(--r);
    border: 1px solid var(--border-2);
    font-size: 12px;
    font-weight: 500;
    color: var(--txt-2);
    text-decoration: none;
    transition: all var(--t);
    background: var(--surface);
}

.pagination a:hover { background: var(--gray-50); color: var(--txt); }
.pagination .active span { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: 0 1px 2px rgba(0,93,203,.2); }
.pagination .disabled span { opacity: .4; cursor: not-allowed; }

/* ── Avatar ── */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--blue-50);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--blue);
    flex-shrink: 0;
    border: 2px solid var(--blue-100);
}

.avatar-xs { width: 24px; height: 24px; font-size: 9px; }
.avatar-sm { width: 30px; height: 30px; font-size: 10px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; font-size: 20px; }

/* ── Dividers ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.divider-dashed { border-top-style: dashed; }

/* ── Empty state ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--txt-3);
    text-align: center;
    gap: 10px;
}

.empty-state i    { font-size: 40px; color: var(--gray-300); }
.empty-state h4   { font-size: 14px; font-weight: 600; color: var(--txt-2); }
.empty-state p    { font-size: 13px; }

/* ── Modal ── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,.5);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: 16px;
}

.modal {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--txt);
    margin-bottom: 16px;
}

.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Bottom sheet */
.sheet {
    background: var(--surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 20px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--gray-300);
    margin: 0 auto 18px;
}

/* ── Toggle switch ── */
.toggle {
    position: relative;
    width: 42px;
    height: 24px;
    display: inline-block;
    flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 12px;
    transition: var(--t-md);
    cursor: pointer;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: var(--t-md);
    box-shadow: var(--shadow-xs);
}

.toggle input:checked + .toggle-slider { background: var(--blue); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Misc utilities ── */
.rounded      { border-radius: var(--r); }
.rounded-full { border-radius: var(--r-full); }
.rounded-lg   { border-radius: var(--r-lg); }
.shadow-xs    { box-shadow: var(--shadow-xs); }
.shadow-sm    { box-shadow: var(--shadow-sm); }
.shadow       { box-shadow: var(--shadow); }
.border       { border: 1px solid var(--border); }
.border-top   { border-top: 1px solid var(--border); }
.border-bottom{ border-bottom: 1px solid var(--border); }
.bg-surface   { background: var(--surface); }
.bg-gray-50   { background: var(--gray-50); }
.cursor-pointer { cursor: pointer; }
.select-none  { user-select: none; }
.pointer-none { pointer-events: none; }
.relative     { position: relative; }
.absolute     { position: absolute; }
.sticky       { position: sticky; }
.fixed        { position: fixed; }
.inset-0      { inset: 0; }
.z-50         { z-index: 50; }

/* ── Print ── */
@media print {
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    body { background: #fff; color: #000; font-size: 12px; }
    .no-print { display: none !important; }
}

/* ── Responsive breakpoints ── */
@media (max-width: 640px) {
    .sm-hidden { display: none !important; }
    .sm-block  { display: block !important; }
    .sm-flex   { display: flex !important; }
    .sm-grid-1 { grid-template-columns: 1fr !important; }
    .sm-grid-2 { grid-template-columns: repeat(2,1fr) !important; }
    .sm-p-3    { padding: 12px !important; }
    .sm-text-sm{ font-size: 12px !important; }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .md-grid-2 { grid-template-columns: repeat(2,1fr) !important; }
    .md-hidden { display: none !important; }
}

@media (min-width: 1025px) {
    .lg-grid-4 { grid-template-columns: repeat(4,1fr) !important; }
}
