*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }

:root {
    --bg:       #f5f7fb;
    --white:    #ffffff;
    --border:   #e2e8f0;
    --border2:  #d1d9e6;
    --accent:   #2563eb;
    --accent-h: #1d4ed8;
    --accent-l: #eff6ff;
    --success:  #16a34a;
    --success-l:#dcfce7;
    --warning:  #d97706;
    --warning-l:#fef3c7;
    --danger:   #dc2626;
    --danger-l: #fee2e2;
    --text:     #0f172a;
    --text2:    #475569;
    --text3:    #94a3b8;
    --radius:   8px;
    --shadow:   0 4px 6px rgba(0,0,0,0.07);
    --shadow2:  0 1px 3px rgba(0,0,0,0.08);
}

body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh; }
body.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* NAVBAR */
.navbar { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 52px; background: var(--white); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow2); }
.nav-brand { display: flex; align-items: center; gap: 8px; }
.nav-logo { font-size: 18px; }
.nav-title { font-weight: 700; font-size: 15px; color: var(--text); letter-spacing: 0.2px; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link { color: var(--text2); text-decoration: none; font-size: 13px; padding: 6px 12px; border-radius: var(--radius); transition: all .15s; }
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { color: var(--accent); background: var(--accent-l); }
.nav-logout { color: var(--danger); }
.nav-logout:hover { background: var(--danger-l); color: var(--danger); }
.nav-user { color: var(--text2); font-size: 13px; padding: 0 12px; border-left: 1px solid var(--border); margin-left: 4px; }

/* PAGE */
.page-content { padding: 20px 24px; max-width: 1200px; margin: 0 auto; }

/* AUTH */
.auth-container { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 40px; width: 360px; box-shadow: var(--shadow); }
.auth-logo { font-size: 36px; text-align: center; margin-bottom: 10px; }
.auth-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.auth-subtitle { text-align: center; color: var(--text3); margin-bottom: 28px; font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* INPUTS */
.input { width: 100%; padding: 8px 10px; background: var(--white); border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text); font-size: 13px; outline: none; transition: border-color .15s, box-shadow .15s; height: 38px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.input:disabled { background: #f1f5f9; color: var(--text3); cursor: not-allowed; }
.input-sm { height: 34px; padding: 6px 10px; font-size: 13px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--text2); letter-spacing: 0.3px; text-transform: uppercase; }

/* BUTTONS */
.btn { padding: 8px 16px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; font-size: 13px; font-weight: 500; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; height: 36px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); border-color: var(--accent-h); }
.btn-secondary { background: var(--white); color: var(--text2); border-color: var(--border2); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-l); }
.btn-ghost { background: transparent; color: var(--accent); border: 1px dashed var(--border2); }
.btn-ghost:hover:not(:disabled) { background: var(--accent-l); border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { height: 30px; padding: 4px 12px; font-size: 12px; }
.btn-icon { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: all .15s; flex-shrink: 0; }
.btn-icon:hover { background: var(--danger-l); color: var(--danger); }

/* ALERTS */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; }
.alert-error { background: var(--danger-l); border: 1px solid #fca5a5; color: var(--danger); }

/* MAIN LAYOUT */
.main-layout { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; height: calc(100vh - 52px - 40px); }

/* LEFT PANEL */
.left-panel { background: var(--white); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.scroll-area { flex: 1; overflow-y: auto; padding: 20px 16px 16px 16px; }
.scroll-area::-webkit-scrollbar { width: 4px; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 8px; }
.panel-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 20px; letter-spacing: 0.2px; }

/* BLOCKS */
.block { margin-bottom: 22px; }
.block-header { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 8px; letter-spacing: 0.2px; text-transform: uppercase; }
.block-header span { color: var(--text3); font-weight: 400; text-transform: none; font-size: 12px; }

/* MODE TABS */
.mode-tabs { display: flex; gap: 3px; background: var(--bg); padding: 3px; border-radius: var(--radius); border: 1px solid var(--border); }
.mode-tab { flex: 1; padding: 6px; border: none; background: none; color: var(--text2); cursor: pointer; border-radius: 6px; font-size: 13px; transition: all .15s; text-align: center; font-weight: 500; }
.mode-tab.active { background: var(--white); color: var(--accent); box-shadow: var(--shadow2); }

/* ENTITY ROWS */
.field-group { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: flex; align-items: center; gap: 6px; }
.field-row .search-wrapper { flex: 1; }

/* AUTOCOMPLETE */
.search-wrapper { position: relative; width: 100%; }
.search-input { width: 100%; padding: 8px 10px; border: 1px solid var(--border2); border-radius: var(--radius); font-size: 13px; background: var(--white); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; height: 38px; }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.search-input:disabled { background: #f1f5f9; color: var(--text3); cursor: not-allowed; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--white); border: 1px solid var(--border2); border-top: none; border-radius: 0 0 var(--radius) var(--radius); max-height: 200px; overflow-y: auto; display: none; z-index: 1000; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.search-results.show { display: block; }
.result-item { padding: 8px 12px; cursor: pointer; font-size: 13px; color: var(--text); transition: background .1s; }
.result-item:hover { background: var(--bg); }
.result-item.selected { background: var(--accent-l); color: var(--accent); }
.no-results { padding: 10px 12px; color: var(--text3); font-size: 13px; text-align: center; }

/* PERIOD GROUP */
.period-group { background: var(--bg); border-radius: 10px; padding: 12px 12px 10px 12px; margin-bottom: 8px; border: 1px solid var(--border); }
.period-top-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.period-top-row select { flex: 1; }
.date-row { display: flex; gap: 8px; }
.date-row .field-wrap { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.date-row label { font-size: 11px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: 0.2px; }
.date-error { color: var(--danger); font-size: 11px; margin-top: 4px; display: none; align-items: center; gap: 4px; }
.date-error.show { display: flex; }
.date-error::before { content: "⚠"; font-size: 12px; }
input.error { border-color: var(--danger) !important; }

/* DIVIDER */
.divider { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* PANEL FOOTER */
.panel-footer { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--white); display: flex; flex-direction: column; gap: 10px; }

/* CHECK RESULT */
.check-result { padding: 10px 12px; background: var(--bg); border-radius: var(--radius); border: 1px solid var(--border); font-size: 13px; }
.check-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; }

/* RIGHT PANEL */
.right-panel { background: var(--white); border: 1px solid var(--border); border-radius: 12px; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.right-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.right-panel-header h3 { font-size: 15px; font-weight: 600; }
.history-filters { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.history-filters .input { flex: 1; }
.history-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 8px; }

/* HISTORY ITEM */
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); cursor: pointer; transition: border-color .15s, background .15s; }
.history-item:hover { border-color: var(--accent); background: var(--accent-l); }
.history-item .meta { flex: 1; overflow: hidden; }
.history-item .title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.history-item .sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.history-item-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* STATUS BADGES */
.status-badge { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.status-done, .status-badge.done { background: var(--success-l); color: var(--success); }
.status-progress, .status-badge.progress { background: var(--warning-l); color: var(--warning); }
.status-error, .status-badge.error { background: var(--danger-l); color: var(--danger); }
.status-pending, .status-badge.pending { background: #f1f5f9; color: var(--text3); }

/* TOAST */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 16px; border-radius: var(--radius); font-size: 13px; box-shadow: var(--shadow); animation: slideIn .25s ease; max-width: 300px; border: 1px solid transparent; }
.toast-success { background: var(--success-l); color: var(--success); border-color: #86efac; }
.toast-error { background: var(--danger-l); color: var(--danger); border-color: #fca5a5; }
.toast-info { background: var(--accent-l); color: var(--accent); border-color: #93c5fd; }
@keyframes slideIn { from { opacity:0; transform: translateX(30px); } to { opacity:1; transform: translateX(0); } }

/* PENDING */
.pending-container { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.pending-card { text-align: center; background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 48px; max-width: 480px; box-shadow: var(--shadow); }
.pending-spinner { width: 44px; height: 44px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 20px; }
@keyframes spin { to { transform: rotate(360deg); } }
.pending-status { font-size: 15px; margin: 14px 0 6px; color: var(--text); }
.pending-hint { color: var(--text3); font-size: 13px; margin-bottom: 20px; }

/* BANNER */
.banner-warning { background: var(--warning-l); border: 1px solid #fcd34d; color: var(--warning); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }

/* EMPTY STATE */
.empty-state { text-align: center; color: var(--text3); padding: 40px 20px; font-size: 13px; }

/* HIDDEN */
.hidden { display: none !important; }
