/* ── Fieldly — Core Styles ─────────────────────────────────────── */
:root {
    --sidebar-width: 240px;
    --topbar-height: 60px;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: rgba(255,255,255,.75);
    --sidebar-active: #fff;
    --sidebar-active-bg: rgba(255,255,255,.12);
    --sidebar-hover-bg: rgba(255,255,255,.07);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --body-bg: #f8fafc;
    --card-bg: #fff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--body-bg); color: var(--text); margin: 0; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.fieldly-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    z-index: 1000; overflow-y: auto;
    transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-icon { width: 36px; height: 36px; background: var(--primary); border-radius: 9px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: 18px; flex-shrink: 0; }
.brand-name { font-size: 16px; font-weight: 800; color: #fff; line-height: 1; }
.brand-sub  { font-size: 11px; color: var(--sidebar-text); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.sidebar-nav { list-style: none; padding: 12px 8px; margin: 0; flex: 1; }
.sidebar-nav li a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none; font-size: 14px; font-weight: 500; transition: background .15s, color .15s; white-space: nowrap; }
.sidebar-nav li a i { font-size: 16px; width: 18px; flex-shrink: 0; }
.sidebar-nav li a:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-active); }
.sidebar-nav li a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.sidebar-nav li a .badge { margin-left: auto; flex-shrink: 0; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.1); }
.user-avatar { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.user-role { font-size: 11px; color: var(--sidebar-text); }
.user-logout { margin-left: auto; color: var(--sidebar-text); font-size: 18px; text-decoration: none; }
.user-logout:hover { color: var(--danger); }

/* ── Content ──────────────────────────────────────────────────── */
.fieldly-content { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
.fieldly-topbar { height: var(--topbar-height); background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 100; }
.page-title { font-size: 18px; font-weight: 700; margin: 0; color: var(--text); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.fieldly-main { flex: 1; padding-top: 24px; }

/* ── Cards ────────────────────────────────────────────────────── */
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-bg); box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--border); padding: 14px 18px; border-radius: var(--radius) var(--radius) 0 0 !important; display: flex; align-items: center; justify-content: space-between; }
.card-header h5, .card-header h6 { margin: 0; font-weight: 700; }
.card-body { padding: 18px; }

/* ── KPI Cards ────────────────────────────────────────────────── */
.kpi-card { border: none; border-radius: 12px; padding: 20px; color: #fff; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 800; line-height: 1; }
.kpi-card .kpi-label { font-size: 12px; opacity: .85; margin-top: 4px; }
.kpi-card .kpi-sub   { font-size: 12px; opacity: .7; margin-top: 6px; }
.kpi-blue   { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.kpi-red    { background: linear-gradient(135deg, #ef4444, #f87171); }
.kpi-green  { background: linear-gradient(135deg, #22c55e, #4ade80); }
.kpi-purple { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.kpi-amber  { background: linear-gradient(135deg, #f59e0b, #fbbf24); }

/* ── Tables ───────────────────────────────────────────────────── */
.table { --bs-table-bg: transparent; }
.table th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); border-bottom: 2px solid var(--border) !important; padding: 10px 12px; }
.table td { padding: 12px; vertical-align: middle; border-color: var(--border); font-size: 14px; }
.table tbody tr:hover { background: #f8fafc; }
.table-actions { display: flex; gap: 4px; justify-content: flex-end; }
.table-actions .btn { padding: 4px 8px; font-size: 12px; }

/* ── Badges & Status ──────────────────────────────────────────── */
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-badge::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-control, .form-select { font-size: 14px; border: 1.5px solid var(--border); border-radius: 8px; padding: 9px 12px; transition: border-color .15s, box-shadow .15s; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); outline: none; }
.form-text { font-size: 11px; color: var(--text-muted); }
.input-group-text { border: 1.5px solid var(--border); background: #f8fafc; font-size: 14px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn { font-size: 14px; font-weight: 600; border-radius: 8px; padding: 8px 16px; transition: all .15s; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; }

/* ── Line Items Table ─────────────────────────────────────────── */
.line-items-table { width: 100%; }
.line-items-table th { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; padding: 8px; background: #f8fafc; border: 1px solid var(--border); }
.line-items-table td { padding: 6px; border: 1px solid var(--border); vertical-align: middle; }
.line-items-table input, .line-items-table select { font-size: 14px !important; min-font-size: 16px; }
.line-items-total { background: #f8fafc; padding: 12px 16px; border-radius: 0 0 var(--radius) var(--radius); border: 1px solid var(--border); border-top: 2px solid var(--border); }

/* ── Tabs ─────────────────────────────────────────────────────── */
.fieldly-tabs { border-bottom: 2px solid var(--border); margin-bottom: 20px; display: flex; gap: 4px; }
.fieldly-tab { padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; }
.fieldly-tab:hover { color: var(--primary); }
.fieldly-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Detail rows ──────────────────────────────────────────────── */
.detail-row { display: flex; padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); width: 140px; flex-shrink: 0; font-size: 13px; }
.detail-value { color: var(--text); font-weight: 500; }

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 991px) {
    .fieldly-content { margin-left: 0; }
    .fieldly-sidebar { transform: translateX(-100%); }
    .fieldly-sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.3); }
    .sidebar-toggle { background: none; border: none; font-size: 22px; color: var(--text); cursor: pointer; padding: 0; }
}
@media (min-width: 992px) { .sidebar-toggle { display: none; } }

/* ── Alerts ───────────────────────────────────────────────────── */
.flash-container .alert { border-radius: var(--radius); font-size: 14px; }

/* ── Notes/Timeline ───────────────────────────────────────────── */
.note-item { padding: 12px; background: #f8fafc; border-radius: var(--radius); border-left: 3px solid var(--primary); margin-bottom: 10px; }
.note-item .note-text { font-size: 14px; color: var(--text); }
.note-item .note-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ── Priority colors ──────────────────────────────────────────── */
.priority-urgent { color: #ef4444; font-weight: 700; }
.priority-high   { color: #f59e0b; font-weight: 600; }
.priority-normal { color: var(--text-muted); }
.priority-low    { color: #94a3b8; }
