/* Shared design tokens and components for kalkulator.tabu.hr */

:root{
  --bg:#F7F7FA;
  --bg-elevated:#FFFFFF;
  --bg-subtle:#ECECF0;
  --text:#121216;
  --text-secondary:#3A3A45;
  --text-muted:#6C6C78;
  --text-subtle:#8A8A96;
  --border:#D1D1D8;
  --border-strong:#B6B6C0;
  --border-subtle:#ECECF0;
  --primary:#BCB2F7;
  --primary-strong:#7469A9;
  --lime:#E0FE90;
  --salmon:#FF9883;
  --ink:#15131F;
  --link:#7469A9;
  --inv-bg:#15131F;
  --inv-fg:#FFFFFF;
  --error:#CF3951;
  --font:"Geist","Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
[data-theme="dark"]{
  color-scheme:dark;
  --bg:#121216;
  --bg-elevated:#17171C;
  --bg-subtle:#26262E;
  --text:#ECECF0;
  --text-secondary:#B6B6C0;
  --text-muted:#8A8A96;
  --text-subtle:#6C6C78;
  --border:#2E2E38;
  --border-strong:#3A3A45;
  --border-subtle:#1E1E25;
  --primary-strong:#BCB2F7;
  --link:#BCB2F7;
  --inv-bg:#BCB2F7;
  --inv-fg:#15131F;
  --error:#F27A8C;
}

*{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{
  font-family:var(--font);
  background:var(--bg);
  color:var(--text);
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
a{color:var(--link)}
button,input,select{font-family:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:2px solid var(--primary-strong);outline-offset:2px}
.num,.amount{font-variant-numeric:tabular-nums}

/* Page frame */
.page{
  display:flex;flex-direction:column;gap:28px;
  max-width:1280px;margin:0 auto;
  padding:clamp(20px,3vw,32px) clamp(16px,3vw,40px) 40px;
}

/* Header */
.site-header{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap}
.site-header__left{display:flex;align-items:center;gap:24px;flex-wrap:wrap}
.site-header__right{display:flex;align-items:center;gap:8px;margin-left:auto}
.logo{display:flex;color:var(--text)}
.logo svg{width:96px;height:auto;display:block}
.back{font-size:14px;color:var(--text-secondary);text-decoration:none}
.back:hover{color:var(--text)}
.site-link{font-size:14px;color:var(--text-secondary);text-decoration:none}
.site-link:hover{color:var(--text)}
.site-header__right .site-link{margin-right:8px}
@media (max-width:600px){.logo svg{width:80px}}

.theme-toggle{
  flex:none;width:40px;height:40px;padding:0;border-radius:999px;
  border:1px solid var(--border);background:var(--bg-elevated);color:var(--text);
  display:flex;align-items:center;justify-content:center;
}
.theme-toggle svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.theme-toggle .icon-sun{display:none}
[data-theme="dark"] .theme-toggle .icon-sun{display:block}
[data-theme="dark"] .theme-toggle .icon-moon{display:none}

.lang-toggle{display:flex;gap:2px;padding:3px;border:1px solid var(--border);border-radius:999px;background:var(--bg-elevated)}
.lang-toggle button{
  border:0;min-width:44px;height:32px;padding:0 12px;border-radius:999px;
  font-size:13px;font-weight:600;background:transparent;color:var(--text-secondary);
}
.lang-toggle button[aria-pressed="true"]{background:var(--inv-bg);color:var(--inv-fg)}

/* Call-to-action link */
.cta{
  display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:44px;
  padding:16px 18px;border-radius:12px;background:var(--inv-bg);color:var(--inv-fg);
  text-decoration:none;font-size:15px;font-weight:600;line-height:1.35;transition:opacity .15s;
}
.cta:hover{opacity:.9}

/* Title block */
.intro{display:flex;flex-direction:column;gap:8px;max-width:820px}
.intro h1{font-size:clamp(28px,4vw,40px);line-height:1.1;font-weight:600;letter-spacing:-.03em;text-wrap:balance}
.intro p{font-size:clamp(15px,1.6vw,17px);line-height:1.5;color:var(--text-muted);text-wrap:pretty}

/* Cards */
.card{
  background:var(--bg-elevated);border:1px solid var(--border-subtle);border-radius:16px;
  padding:clamp(18px,2vw,24px) clamp(16px,2.4vw,28px);
}
.card h2{font-size:18px;font-weight:600;letter-spacing:-.01em}
.card-head{display:flex;align-items:center;justify-content:space-between;gap:12px 16px;flex-wrap:wrap}

/* Field rows */
.fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));column-gap:32px}
.field{
  display:flex;align-items:center;justify-content:space-between;gap:16px;
  padding:12px 0;border-top:1px solid var(--border-subtle);
}
.field label,.field .label{display:flex;flex-direction:column;gap:2px;min-width:0;font-size:15px;line-height:1.35;font-weight:500;text-wrap:pretty}
.field .sub{font-size:13px;line-height:1.45;font-weight:400;color:var(--text-muted)}
.field label{flex:1 1 auto}
.field--wide{flex-direction:column;align-items:stretch;gap:8px}
.field--wide .sel{width:100%}
.field--wide .sel select{width:100%;max-width:none}

/* Number input with a trailing unit */
.num{
  flex:none;display:flex;align-items:center;gap:8px;
  width:112px;height:44px;padding:0 14px;border-radius:8px;background:var(--bg-subtle);
}
.num--money{width:128px}
.num input{
  flex:1;min-width:0;width:100%;border:0;background:transparent;text-align:right;
  font-size:15px;font-weight:600;font-variant-numeric:tabular-nums;
  -moz-appearance:textfield;appearance:textfield;
}
.num input::-webkit-outer-spin-button,.num input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
.num input:focus{outline:none}
.num:focus-within{outline:2px solid var(--primary-strong)}
.num .unit{flex:none;font-size:15px;font-weight:500;color:var(--text-muted)}
.num input::placeholder{color:var(--text-subtle)}

/* Select */
.sel{position:relative;flex:none;display:flex;max-width:100%}
.sel select{
  appearance:none;-webkit-appearance:none;width:auto;min-width:160px;max-width:min(100%,280px);height:44px;
  padding:0 34px 0 14px;border:0;border-radius:8px;background:var(--bg-subtle);
  font-size:15px;font-weight:500;text-overflow:ellipsis;cursor:pointer;
}
.sel::after{
  content:"\25BE";position:absolute;right:14px;top:50%;transform:translateY(-50%);
  font-size:12px;color:var(--text-muted);pointer-events:none;
}
.sel select:focus{outline:2px solid var(--primary-strong)}

/* Switch */
.switch{
  appearance:none;-webkit-appearance:none;flex:none;position:relative;
  width:36px;height:20px;border-radius:999px;background:var(--border-strong);cursor:pointer;transition:background .15s;
}
.switch::before{
  content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;
  background:#fff;transition:transform .15s;
}
.switch:checked{background:var(--primary)}
.switch:checked::before{transform:translateX(16px);background:var(--ink)}

/* Segmented control */
.seg{display:inline-flex;padding:3px;border:1px solid var(--border);border-radius:999px;background:var(--bg-elevated);max-width:100%}
.seg button{
  height:34px;padding:0 14px;border:0;border-radius:999px;background:transparent;
  color:var(--text-secondary);font-size:14px;font-weight:500;white-space:nowrap;transition:background .15s;
}
.seg button:hover{background:var(--bg-subtle)}
.seg button[aria-pressed="true"]{background:var(--primary);color:var(--ink);font-weight:600}
.seg-scroll{overflow-x:auto;margin:0 -16px;padding:0 16px;scrollbar-width:none}
.seg-scroll::-webkit-scrollbar{display:none}
.seg-scroll .seg{width:max-content;max-width:none}

/* Buttons */
.btn{
  display:flex;align-items:center;justify-content:center;width:100%;height:44px;
  border:0;border-radius:12px;font-size:15px;font-weight:600;transition:background .15s,opacity .15s;
}
.btn-primary{background:var(--primary);color:var(--ink)}
.btn-primary:hover{opacity:.9}
.btn-ghost{background:transparent;color:var(--text)}
.btn-ghost:hover{background:var(--bg-subtle)}

/* Group labels and breakdown rows */
.group-label{font-size:12px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--text-muted)}
.row{display:flex;justify-content:space-between;gap:12px;padding:5px 0;font-size:14px}
.row .v{flex:none;font-variant-numeric:tabular-nums;white-space:nowrap}
.row.info{color:var(--text-muted)}
.row.total{font-size:15px;font-weight:600;border-top:1px solid var(--border);padding:10px 0 4px;margin-top:2px}

/* Result tile */
.tile{
  background:var(--primary);color:var(--ink);border-radius:24px;padding:28px;
  display:flex;flex-direction:column;gap:20px;
}
.tile__main{display:flex;flex-direction:column;gap:6px}
.tile__label{font-size:15px;font-weight:500}
.tile__value{font-size:clamp(44px,5vw,56px);line-height:1;font-weight:600;letter-spacing:-.035em;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.tile__grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px}
.mini{background:rgba(255,255,255,.55);border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:2px}
.mini__label{font-size:13px}
.mini__value{font-size:20px;font-weight:600;font-variant-numeric:tabular-nums}

/* Composition bar */
.split{display:flex;flex-direction:column;gap:10px}
.split__title{font-size:13px;font-weight:500;color:var(--text-muted)}
.split__bar{display:flex;height:14px;border-radius:999px;overflow:hidden;gap:2px}
.split__bar span{display:block;min-width:2px}
.split__legend{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:6px 16px}
.split__legend--stack{grid-template-columns:1fr}
.split__item{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--text-secondary)}
.split__item i{flex:none;width:10px;height:10px;border-radius:3px}
.split__item .v{margin-left:auto;flex:none;white-space:nowrap;font-variant-numeric:tabular-nums;color:var(--text)}

/* Accordion */
.acc-head{
  all:unset;box-sizing:border-box;width:100%;cursor:pointer;
  display:flex;align-items:center;justify-content:space-between;gap:16px;
}
.acc-head:hover{background:var(--bg)}
.acc-head:focus-visible{outline:2px solid var(--primary-strong);outline-offset:-2px}
.acc-icon{
  flex:none;width:40px;height:40px;border-radius:999px;border:1px solid var(--border);
  display:flex;align-items:center;justify-content:center;font-size:18px;color:var(--text);
}
.acc-head[aria-expanded="true"] .acc-icon::before,.acc-head[aria-expanded="true"] .acc-mini::before{content:"\2212"}
.acc-head[aria-expanded="false"] .acc-icon::before,.acc-head[aria-expanded="false"] .acc-mini::before{content:"+"}
.acc-mini{color:var(--text-muted)}

/* Workbench layout: inputs left, sticky result right */
.workbench{display:flex;flex-wrap:wrap;gap:24px;align-items:flex-start}
.workbench__inputs{flex:1 1 560px;min-width:0;display:flex;flex-direction:column;gap:16px}
.workbench__aside{
  flex:1 1 360px;max-width:440px;position:sticky;top:24px;
  display:flex;flex-direction:column;gap:12px;scroll-margin-top:16px;
}

/* Mobile result bar */
.mobile-bar{
  display:none;position:fixed;left:12px;right:12px;bottom:12px;z-index:10;
  background:var(--primary);color:var(--ink);border-radius:20px;padding:14px 14px 14px 18px;
  align-items:center;justify-content:space-between;gap:12px;box-shadow:0 10px 30px rgba(21,19,31,.18);
}
.mobile-bar.is-hidden{display:none}
.mobile-bar__text{display:flex;flex-direction:column;gap:2px;min-width:0}
.mobile-bar__label{font-size:13px;font-weight:500}
.mobile-bar__value{font-size:26px;line-height:1;font-weight:600;letter-spacing:-.03em;font-variant-numeric:tabular-nums}
.mobile-bar__sub{font-size:12px;font-variant-numeric:tabular-nums}
.mobile-bar__sub span:last-child{white-space:nowrap}
.mobile-bar a{
  flex:none;min-height:44px;display:flex;align-items:center;padding:0 16px;border-radius:999px;
  background:var(--ink);color:#fff;font-size:14px;font-weight:600;text-decoration:none;
}

/* Notes and errors */
.notes{display:flex;flex-direction:column;gap:6px;font-size:13px;line-height:1.45;color:var(--text-secondary)}
.notes li{list-style:none}
.error{font-size:13px;line-height:1.45;color:var(--error)}
.hint{font-size:13px;line-height:1.5;color:var(--text-muted)}

/* Footer */
.site-footer{
  display:flex;flex-wrap:wrap;justify-content:space-between;gap:8px 24px;
  padding-top:20px;border-top:1px solid var(--border-subtle);
  font-size:14px;line-height:1.5;color:var(--text-muted);
}
.site-footer a{color:var(--link);text-decoration:none}
.site-footer a:hover{text-decoration:underline}
.site-footer__left{display:flex;flex-direction:column;gap:4px}
