/* ── VARIABLES ───────────────────────────────────────────── */
:root {
    --white:      #FFFFFF;
    --bg:         #F5F7FA;
    --bg2:        #FFFFFF;
    --bg3:        #F1F4F8;
    --border:     #E2E8F0;
    --border2:    #CBD5E1;
    --accent:     #4F7EFF;
    --accent-h:   #3B6CE8;
    --accent2:    #7C3AED;
    --success:    #059669;
    --warning:    #D97706;
    --danger:     #DC2626;
    --info:       #0284C7;
    --text:       #1E293B;
    --text2:      #475569;
    --muted:      #94A3B8;
    --sidebar-w:  248px;
    --topbar-h:   60px;
    --radius:     10px;
    --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:  0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);
}

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ── LAYOUT ──────────────────────────────────────────────── */
.app-wrapper    { display: flex; min-height: 100vh; }
.main-content   { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.page-content   { padding: 28px; flex: 1; }

/* ── GUEST LAYOUT ────────────────────────────────────────── */
.guest-wrapper  { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.guest-card     { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px 32px; width: 100%; max-width: 420px; box-shadow: var(--shadow-md); }
.guest-logo     { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 28px; }
.guest-title    { font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 6px; }
.guest-subtitle { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 24px; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    position: fixed; top: 0; left: 0; height: 100vh;
    overflow-y: auto; z-index: 100;
    display: flex; flex-direction: column;
}
.sidebar-logo {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.logo-icon {
    width: 34px; height: 34px;
    background: var(--accent); color: #fff;
    border-radius: 9px; display: flex; align-items: center; justify-content: center;
    font-size: 15px;
}
.logo-text { font-size: 16px; color: var(--text); letter-spacing: -.2px; }
.logo-text strong { color: var(--accent); }

.nav-section-label {
    padding: 14px 18px 5px;
    font-size: 10px; font-weight: 700;
    letter-spacing: 1.2px; text-transform: uppercase;
    color: var(--muted);
}
.nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 16px; margin: 1px 8px;
    border-radius: 8px; color: var(--text2);
    font-size: 13.5px; font-weight: 500;
    transition: all .15s; cursor: pointer;
}
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(79,126,255,.1); color: var(--accent); font-weight: 600; }
.nav-item i      { width: 16px; text-align: center; font-size: 13px; }

.sidebar-bottom  { margin-top: auto; border-top: 1px solid var(--border); padding: 14px 12px; }
.user-card       { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.user-info   { flex: 1; min-width: 0; }
.user-name   { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role   { font-size: 11px; color: var(--muted); }
.logout-btn  { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; font-size: 14px; }
.logout-btn:hover { color: var(--danger); }

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 50;
}
.topbar-title     { font-size: 16px; font-weight: 700; color: var(--text); flex: 1; }
.sidebar-toggle   { display: none; background: none; border: none; color: var(--text2); font-size: 16px; cursor: pointer; }
.topbar-search {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 12px; width: 280px;
}
.topbar-search input  { background: none; border: none; outline: none; color: var(--text); font-size: 13px; width: 100%; }
.topbar-search i      { color: var(--muted); font-size: 12px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; border-radius: 8px; border: none;
    font-size: 13.5px; font-weight: 500; cursor: pointer;
    font-family: 'Inter', sans-serif; transition: all .15s;
    text-decoration: none;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-h); }
.btn-secondary{ background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover{ background: var(--border); color: var(--text); }
.btn-danger   { background: rgba(220,38,38,.1); color: var(--danger); border: 1px solid rgba(220,38,38,.2); }
.btn-danger:hover   { background: rgba(220,38,38,.18); }
.btn-success  { background: rgba(5,150,105,.1); color: var(--success); border: 1px solid rgba(5,150,105,.2); }
.btn-sm       { padding: 6px 12px; font-size: 12.5px; }
.btn-xs       { padding: 4px 9px; font-size: 11.5px; }
.btn-icon     { width: 34px; height: 34px; padding: 0; justify-content: center; background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-icon:hover { background: var(--border); color: var(--text); }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow);
}
.card-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.card-title   { font-size: 15px; font-weight: 700; color: var(--text); }
.card-subtitle{ font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stats-grid   { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card    { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-icon    { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; margin-bottom: 14px; }
.stat-val     { font-size: 28px; font-weight: 800; line-height: 1; color: var(--text); }
.stat-label   { font-size: 12px; color: var(--muted); margin-top: 5px; }
.stat-delta   { font-size: 11.5px; margin-top: 7px; }
.delta-up     { color: var(--success); }
.delta-down   { color: var(--danger); }

.si-blue    { background: rgba(79,126,255,.1);   color: var(--accent); }
.si-purple  { background: rgba(124,58,237,.1);   color: var(--accent2); }
.si-green   { background: rgba(5,150,105,.1);    color: var(--success); }
.si-yellow  { background: rgba(217,119,6,.1);    color: var(--warning); }
.si-red     { background: rgba(220,38,38,.1);    color: var(--danger); }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap   { overflow-x: auto; }
.data-table   { width: 100%; border-collapse: collapse; }
.data-table th{
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .7px; color: var(--muted);
    padding: 11px 14px; text-align: left;
    border-bottom: 1px solid var(--border); background: var(--bg3);
}
.data-table td        { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg3); }
.td-actions           { display: flex; gap: 5px; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge    { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-blue   { background: rgba(79,126,255,.12);  color: var(--accent); }
.badge-purple { background: rgba(124,58,237,.12);  color: var(--accent2); }
.badge-green  { background: rgba(5,150,105,.12);   color: var(--success); }
.badge-yellow { background: rgba(217,119,6,.12);   color: var(--warning); }
.badge-red    { background: rgba(220,38,38,.12);   color: var(--danger); }
.badge-gray   { background: rgba(148,163,184,.15); color: var(--muted); }

/* ── FORMS ───────────────────────────────────────────────── */
.form-group   { margin-bottom: 18px; }
.form-label   { display: block; font-size: 12.5px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.required     { color: var(--danger); }
.form-control {
    width: 100%; background: var(--white);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 13px; color: var(--text); font-size: 13.5px;
    font-family: 'Inter', sans-serif; outline: none; transition: border .15s;
}
.form-control:focus   { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,126,255,.1); }
.form-control::placeholder { color: var(--muted); }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-hint    { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.form-error   { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ── ALERTS ──────────────────────────────────────────────── */
.flash-container { padding: 0 24px; margin-top: 16px; }
.guest-flash     { margin-bottom: 16px; }
.alert        { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 8px; font-size: 13.5px; position: relative; margin-bottom: 8px; }
.alert-success{ background: rgba(5,150,105,.08); border: 1px solid rgba(5,150,105,.25); color: var(--success); }
.alert-error  { background: rgba(220,38,38,.08);  border: 1px solid rgba(220,38,38,.25);  color: var(--danger); }
.alert-close  { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 16px; color: inherit; opacity: .7; }

/* ── UPLOAD ZONE ─────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border2); border-radius: var(--radius);
    padding: 48px 24px; text-align: center; cursor: pointer; transition: all .2s;
}
.upload-zone:hover  { border-color: var(--accent); background: rgba(79,126,255,.03); }
.upload-zone.drag-over { border-color: var(--accent); background: rgba(79,126,255,.06); }
.upload-icon        { font-size: 40px; color: var(--accent); margin-bottom: 14px; }
.upload-title       { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.upload-subtitle    { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* ── PDF GRID ────────────────────────────────────────────── */
.pdf-grid     { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.pdf-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; cursor: pointer;
    transition: all .2s; position: relative;
}
.pdf-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.pdf-thumb {
    width: 100%; height: 100px; background: var(--bg3);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px; font-size: 32px; color: var(--accent);
}
.pdf-name     { font-weight: 600; font-size: 13px; line-height: 1.4; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-meta     { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pdf-hover-actions { position: absolute; top: 10px; right: 10px; display: none; gap: 4px; }
.pdf-card:hover .pdf-hover-actions { display: flex; }

/* ── TABLE GRID ──────────────────────────────────────────── */
.table-grid   { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.table-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; cursor: pointer;
    transition: all .2s; box-shadow: var(--shadow);
}
.table-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.table-card-icon  { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 14px; }
.table-card-name  { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.table-card-desc  { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }
.table-card-stats { display: flex; gap: 16px; font-size: 12px; color: var(--text2); }

/* ── FILTER BAR ──────────────────────────────────────────── */
.filter-bar   { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
    padding: 5px 13px; border-radius: 20px;
    border: 1px solid var(--border); font-size: 12.5px;
    font-weight: 500; color: var(--text2); cursor: pointer; transition: all .15s;
    background: var(--white);
}
.chip:hover, .chip.active { background: rgba(79,126,255,.1); border-color: var(--accent); color: var(--accent); }

/* ── PROGRESS BAR ────────────────────────────────────────── */
.progress-bar { height: 6px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.progress-fill{ height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }

/* ── TABS ────────────────────────────────────────────────── */
.tabs         { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab {
    padding: 10px 18px; font-size: 13.5px; font-weight: 500;
    color: var(--text2); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.tab:hover    { color: var(--text); }
.tab.active   { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── LINKED ITEMS ────────────────────────────────────────── */
.linked-item  { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--bg3); border-radius: 8px; margin-bottom: 7px; border: 1px solid var(--border); }
.linked-item i{ color: var(--accent); font-size: 13px; }
.linked-label { flex: 1; font-size: 13px; font-weight: 500; }
.linked-type  { font-size: 11px; color: var(--muted); background: var(--white); padding: 2px 7px; border-radius: 4px; border: 1px solid var(--border); }

/* ── SEARCH RESULTS ──────────────────────────────────────── */
.search-result {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    margin-bottom: 10px; cursor: pointer; transition: all .15s;
    display: flex; gap: 14px;
}
.search-result:hover  { border-color: var(--accent); box-shadow: var(--shadow-md); }
.result-icon  { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.result-icon-pdf   { background: rgba(79,126,255,.12);  color: var(--accent); }
.result-icon-row   { background: rgba(5,150,105,.12);   color: var(--success); }
.result-title { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.result-snippet{ font-size: 12.5px; color: var(--text2); line-height: 1.6; }
.result-meta  { font-size: 11.5px; color: var(--muted); margin-top: 6px; display: flex; gap: 12px; }
mark          { background: rgba(251,191,36,.3); color: var(--warning); padding: 1px 2px; border-radius: 3px; }

/* ── ACTIVITY FEED ───────────────────────────────────────── */
.activity-item{ display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.activity-time{ font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-header-left h1 { font-size: 22px; font-weight: 800; color: var(--text); }
.page-header-left p  { font-size: 13px; color: var(--muted); margin-top: 3px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* ── SUMMARY BAR ─────────────────────────────────────────── */
.summary-bar  { display: flex; gap: 20px; padding: 10px 16px; background: var(--bg3); border-radius: 8px; margin-bottom: 18px; border: 1px solid var(--border); }
.sbar-item    { font-size: 12.5px; color: var(--text2); }
.sbar-item strong { color: var(--text); font-weight: 700; }

/* ── PAGINATION ──────────────────────────────────────────── */
.pagination   { display: flex; gap: 4px; align-items: center; }
.page-link    { padding: 6px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; color: var(--text2); background: var(--white); cursor: pointer; transition: .15s; }
.page-link:hover     { background: var(--bg3); color: var(--text); }
.page-link.active    { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-link.disabled  { opacity: .4; cursor: not-allowed; }

/* ── FIELD BUILDER ROW ───────────────────────────────────── */
.field-row    { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 7px; }
.field-drag   { color: var(--muted); cursor: grab; font-size: 13px; }
.field-type-chip { font-size: 11px; color: var(--text2); background: var(--white); padding: 2px 8px; border-radius: 4px; border: 1px solid var(--border); }
.field-label  { flex: 1; font-size: 13px; font-weight: 600; }

/* ── REPEATER ROW ────────────────────────────────────────── */
.repeater-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 10px; }
.repeater-row .form-group { flex: 1; margin-bottom: 0; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay{ position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 200; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: .2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal        { background: var(--white); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 20px 22px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 16px; font-weight: 700; }
.modal-body   { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state  { text-align: center; padding: 60px 20px; }
.empty-state i{ font-size: 48px; color: var(--muted); margin-bottom: 16px; display: block; opacity: .5; }
.empty-state h3{ font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 13.5px; color: var(--muted); margin-bottom: 20px; }

/* ── TWO COLUMN LAYOUT ───────────────────────────────────── */
.two-col      { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.three-col    { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg3); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar          { transform: translateX(-100%); transition: transform .3s; }
    .sidebar.open     { transform: translateX(0); }
    .main-content     { margin-left: 0; }
    .sidebar-toggle   { display: flex; }
    .stats-grid       { grid-template-columns: repeat(2, 1fr); }
    .two-col          { grid-template-columns: 1fr; }
    .three-col        { grid-template-columns: 1fr 1fr; }
    .form-row         { grid-template-columns: 1fr; }
    .topbar-search    { display: none; }
}
