/* GoticTeam Accounting — application theme */
:root {
    /* GOTIC brand — golden-yellow on near-black */
    --brand: #F5C21B;
    --brand-dark: #d9a400;
    --ink: #15161a;
    --ink-2: #23252c;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --sidebar: #15161a;
    --sidebar-2: #26282f;
    --sidebar-text: #b9bcc4;
    --sidebar-active: #F5C21B;
    --primary: #F5C21B;
    --primary-dark: #d9a400;
    --primary-ink: #15161a;
    --link: #1d4ed8;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e6e8ec;
    --green: #16a34a;
    --green-bg: #dcfce7;
    --amber: #d97706;
    --amber-bg: #fef3c7;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --blue: #2563eb;
    --blue-bg: #dbeafe;
    --gold-bg: #fdf3d0;
    --gold-text: #8a6d00;
    --gray-bg: #f1f3f5;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15,20,30,.08), 0 1px 2px rgba(15,20,30,.04);
    --shadow-lg: 0 14px 34px -8px rgba(15,20,30,.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .5rem; font-weight: 600; color: var(--text); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
}
.sidebar .brand {
    padding: 20px; font-size: 18px; font-weight: 700; color: #fff;
    display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--sidebar-2);
}
.sidebar .brand .logo {
    width: 32px; height: 32px; border-radius: 8px; background: var(--primary);
    display: grid; place-items: center; font-size: 16px;
}
.nav { padding: 12px 8px; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: #3a3d46 transparent; overscroll-behavior: contain; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: #34363f; border-radius: 999px; }
.nav::-webkit-scrollbar-thumb:hover { background: var(--brand); }
/* Hide the scrollbar until the sidebar is hovered, for a cleaner look */
.nav { scrollbar-color: transparent transparent; }
.sidebar:hover .nav { scrollbar-color: #3a3d46 transparent; }
.nav::-webkit-scrollbar-thumb { background: transparent; }
.sidebar:hover .nav::-webkit-scrollbar-thumb { background: #34363f; }
.sidebar:hover .nav::-webkit-scrollbar-thumb:hover { background: var(--brand); }
.nav .group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 14px 12px 6px; }
.nav a {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
    color: var(--sidebar-text); font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: var(--sidebar-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--brand); color: var(--ink); font-weight: 700; }
.nav a.active .ico { opacity: 1; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }

.main { flex: 1; margin-left: 250px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar .page-title { font-size: 16px; font-weight: 600; }
.topbar .user { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--ink);
    display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.content { padding: 24px; flex: 1; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.accent { border-top: 3px solid var(--primary); }
.kpi.green .value { color: var(--green); }
.kpi.red .value { color: var(--red); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
    border: 1px solid transparent; font-weight: 600; font-size: 13px; cursor: pointer; background: var(--gray-bg); color: var(--text);
    transition: all .15s; text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-warning { background: var(--amber); color: #fff; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--muted); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; font-weight: 600; }
table.data tbody tr:hover { background: #fafbfc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: var(--gray-bg); color: var(--muted); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245,194,27,.28); }
textarea { resize: vertical; min-height: 70px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- Line items editor ---------- */
table.items { width: 100%; border-collapse: collapse; }
table.items th, table.items td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.items th { font-size: 11px; text-transform: uppercase; color: var(--muted); text-align: left; }
table.items input, table.items select { padding: 7px 9px; }
table.items td.num input { text-align: right; }
.line-remove { color: var(--red); cursor: pointer; background: none; border: none; font-size: 18px; line-height: 1; }
.totals-box { max-width: 320px; margin-left: auto; margin-top: 16px; }
.totals-box .row { display: flex; justify-content: space-between; padding: 6px 0; }
.totals-box .row.grand { border-top: 2px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 700; }

/* ---------- Flash ---------- */
.flash-wrap { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 12px 16px; border-radius: 8px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.flash.success { background: var(--green-bg); color: #166534; }
.flash.error { background: var(--red-bg); color: #991b1b; }
.flash.info { background: var(--blue-bg); color: #1e40af; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .actions { display: flex; gap: 10px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 8px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: radial-gradient(1200px 500px at 50% -10%, rgba(245,194,27,.18), transparent 60%), linear-gradient(160deg, #15161a, #26282f); }
.auth-card { text-align: left; }
.auth-card .brand-head { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 18px; }
.auth-card .brand-head h1 { font-size: 20px; margin: 10px 0 2px; letter-spacing: .04em; }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 36px; }
.auth-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.auth-card .brand .logo { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 20px; font-weight: 700; }
.auth-card h1 { font-size: 20px; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }

/* ---------- Document view ---------- */
.doc { background: #fff; }
.doc-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 28px; border-bottom: 2px solid var(--border); }
.doc-header .company h2 { font-size: 20px; margin-bottom: 4px; }
.doc-header .doc-meta { text-align: right; }
.doc-header .doc-meta h1 { font-size: 26px; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; }
.doc-parties { display: flex; justify-content: space-between; padding: 24px 28px; gap: 24px; }
.doc-parties .block .k { font-size: 11px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 4px 24px; }
.detail-grid .item { padding: 6px 0; }
.detail-grid .item .k { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.detail-grid .item .v { font-weight: 600; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .icon { font-size: 40px; opacity: .4; }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex !important; }
    .form-grid, .split { grid-template-columns: 1fr; }
}
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; }

/* ---------- Brand logo ---------- */
.brand .logo-img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; display: block; }
.sidebar .brand { letter-spacing: .02em; text-transform: uppercase; font-weight: 800; }
.auth-logo { width: 84px; height: 84px; border-radius: 18px; object-fit: cover; box-shadow: var(--shadow-lg); margin-bottom: 6px; }
.doc-logo { width: 74px; height: 74px; border-radius: 12px; object-fit: cover; }

/* ---------- Gold badge ---------- */
.badge-gold { background: var(--gold-bg); color: var(--gold-text); }

/* ---------- Permission grid ---------- */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.perm-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.perm-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }

/* ---------- Dashboard mini bar chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding: 8px 4px 0; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; max-width: 42px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--brand), var(--brand-dark)); min-height: 3px; transition: height .3s; }
.chart .bar.expense { background: linear-gradient(180deg, #2a2c33, #15161a); }
.chart .bar-label { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

.kpi.brand-accent { border-top: 3px solid var(--brand); }
.kpi .value.brand { color: var(--brand-dark); }

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .no-print, .form-actions { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; }
    body { background: #fff; }
    .card { border: none; box-shadow: none; }
}
