@font-face{font-family:Inter;src:url("fonts/inter-400.woff2") format("woff2");font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:Inter;src:url("fonts/inter-700.woff2") format("woff2");font-weight:700;font-style:normal;font-display:swap}
:root{
  --ink:#111827;
  --muted:#64748b;
  --line:#dbe3ec;
  --line-strong:#c4cfdb;
  --bg:#f3f6f9;
  --surface:#fff;
  --surface-soft:#f8fafc;
  --brand:#245b8f;
  --brand-hover:#19466f;
  --brand-soft:#eaf2f9;
  --nav:#0e1d2d;
  --nav-hover:#1b3045;
  --danger:#b42318;
  --danger-soft:#fff0ef;
  --success:#176b4d;
  --shadow:0 10px 32px rgba(15,35,55,.07)
}

*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.45 Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}
button,input,select,textarea{font:inherit}
button{line-height:1.2}
a{color:inherit;text-decoration:none}
[hidden]{display:none!important}

.topbar{position:relative;z-index:20;min-height:70px;padding:0 max(24px,calc((100% - 1500px)/2));background:var(--nav);color:#fff;display:flex;align-items:center;justify-content:space-between;gap:30px;border-bottom:1px solid #26394b}
.brand{font-size:18px;letter-spacing:.055em;white-space:nowrap}
.brand span{color:#73a7d4;font-weight:800}
.brand small{display:block;font-size:10px;letter-spacing:.18em;color:#9fb3c7}
.topbar nav{display:flex;align-items:center;gap:5px}
.topbar nav a,.nav-link{color:#cbd7e3;padding:10px 12px;border:0;background:none;cursor:pointer;border-radius:8px}
.topbar nav a:hover,.nav-link:hover,.topbar nav>a.active,.nav-menu.current>.nav-menu-toggle{background:var(--nav-hover);color:#fff}
.topbar nav form{margin:0}
.nav-toggle{display:none;border:1px solid rgba(255,255,255,.18);border-radius:8px;width:44px;height:42px;min-height:42px;padding:0;background:transparent;color:#fff}
.nav-menu{position:relative}
.nav-menu-toggle{gap:7px}
.nav-chevron{font-size:16px;line-height:1;transition:transform .18s ease}
.nav-menu.open .nav-chevron{transform:rotate(180deg)}
.nav-submenu{position:absolute;top:calc(100% + 9px);right:0;width:270px;padding:7px;background:#fff;border:1px solid var(--line);border-radius:11px;box-shadow:0 18px 45px rgba(4,17,30,.22);display:none}
.nav-menu.open .nav-submenu{display:grid;gap:3px}
.topbar .nav-submenu a{display:grid;grid-template-columns:32px 1fr;align-items:center;gap:9px;padding:10px;color:var(--ink);border-radius:8px}
.topbar .nav-submenu a:hover,.topbar .nav-submenu a.active{background:var(--brand-soft);color:#163c60}
.nav-submenu strong{display:block;font-size:13px;line-height:1.25}
.nav-submenu small{margin-top:2px;font-size:11px}
.submenu-icon{display:grid;place-items:center;width:30px;height:30px;border-radius:7px;background:#edf3f8;color:var(--brand)}
.language-switch{display:flex;gap:2px;padding:3px;border:1px solid rgba(255,255,255,.18);border-radius:8px}
.language-switch a{padding:4px 7px!important;font-size:11px}
.language-switch a.active{background:#e8eef5!important;color:#14283c!important}
.auth-language{position:fixed;right:22px;top:18px}
.auth-language .language-switch{border-color:var(--line-strong)}
.auth-language .language-switch a{color:var(--muted)}
.auth-language .language-switch a.active{background:var(--brand)!important;color:#fff!important}

.shell{max-width:1500px;margin:0 auto;padding:30px 24px 70px}
.auth-shell{min-height:100vh;display:grid;place-items:center;padding:24px;background:radial-gradient(circle at 12% 10%,#dce9f5,transparent 34%),#edf2f7}
.auth-card{width:min(440px,100%);background:var(--surface);border:1px solid var(--line);padding:38px;border-radius:16px;box-shadow:var(--shadow)}
.logo{letter-spacing:.1em;color:#203247}
.logo b{color:var(--brand)}
h1{font-size:28px;line-height:1.2;margin:6px 0}
h2{font-size:18px;line-height:1.3;margin:8px 0 18px}
p{color:var(--muted);margin:4px 0 18px}

label{display:flex;flex-direction:column;align-items:stretch;gap:7px;margin:0 0 15px;font-weight:650;font-size:13px;min-width:0}
input,select,textarea{display:block;width:100%;min-height:46px;border:1px solid var(--line-strong);background:var(--surface);border-radius:8px;padding:10px 12px;color:var(--ink);outline:none}
textarea{resize:vertical;line-height:1.45}
input:focus,select:focus,textarea:focus{border-color:var(--brand);box-shadow:0 0 0 3px rgba(36,91,143,.12)}
small{display:block;color:var(--muted);font-weight:400;line-height:1.35}

button,.button{display:inline-flex;min-height:42px;align-items:center;justify-content:center;border:0;border-radius:8px;padding:10px 16px;cursor:pointer;font-weight:700}
.primary{background:var(--brand);color:#fff}
.primary:hover{background:var(--brand-hover)}
.primary:disabled{opacity:.45;cursor:not-allowed}
.secondary{background:var(--surface);border:1px solid var(--line);color:var(--ink)}
.secondary:hover{border-color:var(--line-strong);background:var(--surface-soft)}
.wide{width:100%;display:flex}
.center{text-align:center}
.muted-link{display:block;text-align:center;color:var(--muted);margin-top:18px}

.page-head{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:22px}
.page-head p{margin:0}
.actions{display:flex;align-items:center;gap:8px}
.sticky-head{position:sticky;top:0;background:rgba(243,246,249,.95);backdrop-filter:blur(12px);z-index:5;padding:10px 0}
.card{background:var(--surface);border:1px solid var(--line);border-radius:13px;box-shadow:var(--shadow);margin-bottom:20px;overflow:hidden}
.toolbar{padding:15px;border-bottom:1px solid var(--line)}
.search{max-width:430px}
.budget-search{display:flex;align-items:center;gap:8px}
.budget-search .search{flex:1}
.budget-filters{max-width:none}
.budget-filters select{width:auto;min-width:170px}
.budget-client{display:grid;gap:3px;min-width:220px}
.budget-client small{font-size:12px}
.table-wrap{overflow:auto}
table{width:100%;border-collapse:collapse}
th,td{text-align:left;padding:14px 16px;border-bottom:1px solid #e9eef3;vertical-align:middle}
th{font-size:11px;color:#53677b;text-transform:uppercase;letter-spacing:.065em;background:var(--surface-soft)}
.sort-link{display:inline-flex;align-items:center;min-height:28px;color:inherit}
.sort-link:hover{color:var(--brand)}
.budget-list td:first-child small{margin-top:4px}
tbody tr:last-child td{border-bottom:0}
.num{text-align:right;font-variant-numeric:tabular-nums}
.empty,.placeholder{text-align:center;padding:60px 25px;color:var(--muted)}
.status{display:inline-block;background:#e8f2ed;color:var(--success);padding:4px 9px;border-radius:99px;font-size:12px}
.status.inactive{background:#eef1f4;color:#647178}
.status-custom{background:color-mix(in srgb,var(--status-color) 11%,white);color:var(--status-color);border:1px solid color-mix(in srgb,var(--status-color) 23%,white)}
.color-chip{display:inline-flex;align-items:center;gap:7px}
.color-chip:before{content:"";width:13px;height:13px;border-radius:50%;background:var(--chip-color);box-shadow:0 0 0 1px rgba(0,0,0,.12)}
.icon-btn{display:inline-grid;width:38px;height:38px;min-height:38px;place-items:center;border:1px solid var(--line);border-radius:8px;background:var(--surface);padding:0;color:#17283a}
.icon-btn:hover{border-color:#aebdca;background:var(--surface-soft)}
.danger-icon,.danger-link{color:var(--danger)}
.danger-button{color:var(--danger);background:var(--danger-soft);border:1px solid #f1b7b2}
.danger-icon:hover{border-color:#f1b7b2;background:var(--danger-soft)}
.danger-link{background:none;padding:5px;min-height:0}
.row-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;min-height:42px}
.row-actions form{margin:0}
.alert{padding:13px 16px;border-radius:9px;margin-bottom:18px}
.alert.success{background:#e8f4ee;color:#135f49}
.alert.error{background:#feeceb;color:#8d211a}
.pagination{display:flex;justify-content:center;gap:5px;padding:16px}
.pagination a{min-width:36px;height:36px;display:grid;place-items:center;border:1px solid var(--line);border-radius:8px}
.pagination a.active{background:var(--brand);color:#fff}
.pagination a.disabled{pointer-events:none;opacity:.35}

.grid-2,.grid-3,.grid-4{display:grid;align-items:start;gap:17px 20px}
.grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.grid-4{grid-template-columns:repeat(4,minmax(0,1fr))}
.grid-2>label,.grid-3>label,.grid-4>label{margin-bottom:0}
.span-2{grid-column:span 2}
.check{display:flex;flex-direction:row;align-items:center;gap:10px;min-height:46px}
.check input{width:auto;min-height:0}
.field-help{font-size:12px;margin-top:-8px}
.form-card{padding:26px}
.form-card h2{border-top:1px solid var(--line);padding-top:22px;margin-top:24px}
.form-card h2:first-child{border-top:0;padding-top:0}
.form-actions{display:flex;justify-content:flex-end;margin-top:22px}
.tabs{display:flex;gap:5px;border-bottom:1px solid var(--line);margin-bottom:20px}
.tabs button{background:none;color:var(--muted);border-radius:8px 8px 0 0}
.tabs button.active{color:var(--brand);box-shadow:inset 0 -3px var(--brand)}
.section-head{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:22px 24px}
.section-head h2{margin-bottom:5px}
.section-head p{margin:0}

.lines-table{table-layout:fixed}
.lines-table .col-number{width:6%}
.lines-table .col-description{width:42%}
.lines-table .col-quantity{width:8%}
.lines-table .col-unit{width:9%}
.lines-table .col-price{width:9%}
.lines-table .col-tax{width:7%}
.lines-table .col-amount{width:11%}
.lines-table .col-actions{width:8%}
.lines-table th,.lines-table td{padding:12px 9px}
.lines-table th:first-child,.lines-table td:first-child{padding-left:18px}
.lines-table th:last-child,.lines-table td:last-child{padding-right:18px}
.lines-table input,.lines-table select,.lines-table textarea{min-width:0;min-height:44px;padding:8px 9px}
.lines-table .desc{min-width:0;min-height:76px;padding:8px 9px;border:1px solid var(--line-strong);border-radius:8px;background:var(--surface);line-height:1.45;overflow:auto;user-select:text;cursor:text;position:relative;z-index:1}
.lines-table .desc:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px rgba(36,91,143,.12)}
.lines-table .desc p{margin:0 0 6px;color:inherit}
.lines-table .desc p:last-child{margin-bottom:0}
.line-number{white-space:nowrap;color:#506478;font-variant-numeric:tabular-nums}
.drag{display:inline-block;margin-right:5px;cursor:grab;color:#91a1b0;font-size:17px;vertical-align:middle;user-select:none;touch-action:none}
.drag:active{cursor:grabbing}
.line-total{white-space:nowrap}
.line-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;min-height:76px}
.line-actions .icon-btn{flex:0 0 36px;width:36px;height:36px;min-height:36px}
.lines-table tr.dragging{opacity:.5}
.chapter-row td{background:#edf3f8;border-top:1px solid #c8d7e5;border-bottom:1px solid #c8d7e5;padding-top:10px;padding-bottom:10px}
.chapter-row .line-actions{min-height:54px}
.chapter-kicker{display:block;color:var(--brand);font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.09em;margin-bottom:3px}
.lines-table .chapter-desc{min-height:44px;height:auto;font-weight:750;color:#14283b;background:#f8fbfd;border-color:#bed0df}
.totals{margin-left:auto;width:min(450px,100%);padding:22px 24px}
.totals div{display:flex;justify-content:space-between;padding:8px}
.totals .tax-breakdown{display:block;padding:0}
.totals .tax-breakdown>div{display:flex}
.totals .discount-row{align-items:center;gap:20px}
.totals .discount-row label{margin:0}
.money-input{display:flex!important;align-items:center;padding:0!important;width:145px;border:1px solid var(--line-strong);border-radius:8px;overflow:hidden}
.money-input input{min-height:40px;border:0;border-radius:0;text-align:right;padding:7px 5px 7px 9px}
.money-input input:focus{box-shadow:none}
.money-input span{padding:0 10px;color:var(--muted)}
.totals .grand{font-size:19px;border-top:2px solid var(--ink);margin-top:8px;padding-top:13px}
.input-actions{display:flex}
.input-actions input{border-radius:8px 0 0 8px}
.input-actions a{display:grid;place-items:center;min-width:44px;border:1px solid var(--line-strong);border-left:0;cursor:pointer;background:var(--surface-soft)}
.input-actions a:last-child{border-radius:0 8px 8px 0}

dialog{width:min(740px,calc(100% - 30px));border:0;border-radius:14px;padding:0;box-shadow:0 30px 85px rgba(3,15,28,.28)}
.dialog-wide{width:min(1040px,calc(100% - 30px))}
dialog::backdrop{background:rgba(8,22,36,.58)}
dialog form{padding:24px}
.dialog-head,.dialog-actions{display:flex;align-items:center;justify-content:space-between;gap:10px}
.dialog-head{margin-bottom:18px}
.dialog-head h2{margin:0}
.dialog-head button{font-size:25px;background:none;padding:4px;min-height:36px}
.dialog-actions{justify-content:flex-end;margin-top:20px}
.catalog-picker{border:1px solid var(--line);border-radius:10px;padding:13px;margin-bottom:16px;background:var(--surface-soft)}
.catalog-picker label{margin-bottom:9px}
.catalog-picker [data-catalog-results]{display:grid;gap:6px;max-height:190px;overflow:auto}
.catalog-picker [data-catalog-results] button{text-align:left;background:var(--surface);border:1px solid var(--line);display:flex;justify-content:space-between;gap:14px;min-height:42px}
.catalog-picker [data-catalog-results] span{color:var(--muted);font-weight:400;white-space:nowrap}
.type-switch{display:flex;flex-direction:row;align-items:flex-start;gap:11px;border:1px solid #c8d8e7;background:var(--brand-soft);border-radius:10px;padding:13px 14px;margin-bottom:17px}
.type-switch input{width:auto;min-height:0;margin-top:3px;accent-color:var(--brand)}
.type-switch span{display:grid;gap:2px}
.type-switch strong{color:#183c5e}
.style-sample{display:inline-block;padding:5px 8px;border:1px solid var(--line);border-radius:6px;background:var(--surface-soft)}

.rich-editor{display:grid;border:1px solid var(--line-strong);border-radius:9px;background:var(--surface);overflow:hidden;font-weight:400}
.rich-editor:focus-within{border-color:var(--brand);box-shadow:0 0 0 3px rgba(36,91,143,.12)}
.rich-editor textarea{display:none}
.rich-toolbar{display:flex;align-items:center;gap:3px;padding:6px;border-bottom:1px solid var(--line);background:var(--surface-soft);flex-wrap:wrap}
.rich-toolbar button{width:34px;height:32px;min-height:32px;padding:0;border:1px solid transparent;background:transparent;color:#263a4d}
.rich-toolbar button:hover{border-color:var(--line-strong);background:#fff}
.rich-toolbar button:nth-child(2){font-style:italic}
.rich-toolbar button:nth-child(3){text-decoration:underline}
.rich-color{width:44px;min-height:32px;height:32px;padding:3px;border-radius:6px;font-weight:800}
.rich-surface{min-height:140px;padding:12px;outline:none;overflow:auto;line-height:1.5}
.rich-surface p{margin:0 0 9px;color:inherit}
.rich-surface ul,.rich-surface ol{margin:6px 0;padding-left:24px}
.rich-surface a{color:var(--brand);text-decoration:underline}

@media(max-width:1180px){
  .grid-4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .lines-table{min-width:1180px}
}

@media(max-width:1020px){
  .topbar{height:auto;min-height:62px;padding:12px 18px;flex-wrap:wrap}
  .nav-toggle{display:block;background:none;color:#fff;font-size:23px}
  .topbar nav{display:none;width:100%;flex-direction:column;align-items:stretch}
  .topbar nav.open{display:flex}
  .topbar nav a,.nav-link{display:flex;width:100%;text-align:left}
  .topbar nav>form,.topbar nav>form .nav-link{width:100%}
  .nav-menu{width:100%}
  .nav-menu-toggle{justify-content:flex-start}
  .nav-chevron{margin-left:auto}
  .nav-submenu{position:static;width:100%;margin:3px 0 4px;padding:5px 5px 5px 15px;background:rgba(255,255,255,.055);border-color:rgba(255,255,255,.1);box-shadow:none}
  .topbar .nav-submenu a{color:#cbd7e3}
  .topbar .nav-submenu a:hover,.topbar .nav-submenu a.active{background:rgba(255,255,255,.08);color:#fff}
  .nav-submenu small{color:#91a7ba}
  .submenu-icon{background:rgba(255,255,255,.08);color:#9cc4e5}
  .topbar .language-switch{align-self:flex-start}
  .shell{padding:20px 14px 60px}
  .page-head{align-items:flex-start}
  .grid-2,.grid-3,.grid-4{grid-template-columns:1fr}
  .span-2{grid-column:auto}
  .tabs{overflow:auto}
  .lines-card{border-radius:9px}
  .auth-card{padding:27px}
  .catalog-picker [data-catalog-results] button{display:grid}
  .row-actions{white-space:nowrap}
  .budget-filters select{width:100%}
  .sticky-head .actions{flex-wrap:wrap;justify-content:flex-end}
}

@media(max-width:560px){
  h1{font-size:24px}
  .topbar{padding-inline:14px;gap:14px}
  .brand{font-size:16px}
  .brand small{font-size:9px}
  .page-head{display:grid}
  .page-head .actions{width:100%}
  .page-head .actions>*{flex:1}
  .sticky-head{position:static}
  .sticky-head .actions{display:grid;grid-template-columns:1fr 1fr;width:100%}
  .sticky-head .actions .primary{grid-column:1/-1}
  .section-head{align-items:flex-start;display:grid}
  .section-head button{width:100%}
  .form-card{padding:20px}
  dialog form{padding:20px}
  .budget-search{align-items:stretch;display:grid}
  .budget-search .search{max-width:none}
  .tabs button{padding-inline:12px;white-space:nowrap}
  th,td{padding:12px}
  .totals{padding:18px 14px}
}
