@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;700&display=swap');

:root{
  --bg:#edf1f5;
  --card:rgba(255,255,255,.94);
  --card-strong:#ffffff;
  --text:#0c1412;
  --muted:rgba(12,20,18,.7);
  --border:rgba(15,23,32,.08);
  --shadow:0 20px 52px rgba(15,23,32,.08);
  --shadow-soft:0 10px 24px rgba(15,23,32,.05);
  --radius:24px;
  --radius-sm:16px;
  --green:#1f7a57;
  --green-strong:#0f5a3d;
  --gold:#c88c3a;
  --surface:#f7f8fb;
}

*{ box-sizing:border-box; }
html{ scroll-behavior:smooth; }
body{
  margin:0;
  min-height:100vh;
  color:var(--text);
  font-family:'IBM Plex Sans', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(31,122,87,.08), transparent 34%),
    radial-gradient(circle at top right, rgba(200,140,58,.1), transparent 28%),
    linear-gradient(180deg, #eef3f8 0%, #f5f3ed 100%);
}

a{ color:inherit; text-decoration:none; }
button, input, select, textarea{ font:inherit; }

input, select, textarea, button{
  -webkit-appearance:none;
}

.bg-orb{
  position:fixed;
  inset:auto;
  border-radius:999px;
  filter:blur(36px);
  opacity:.55;
  pointer-events:none;
  z-index:0;
}
.bg-orb--one{ width:260px; height:260px; background:rgba(31,122,87,.12); top:12px; left:-90px; }
.bg-orb--two{ width:220px; height:220px; background:rgba(200,140,58,.14); top:100px; right:-70px; }

.app-shell{
  position:relative;
  z-index:1;
  width:min(1200px, calc(100vw - 24px));
  margin:0 auto;
  padding:18px 0 28px;
}

.brand-mark{
  width:56px;
  height:56px;
  border-radius:18px;
  display:grid;
  place-items:center;
  font:700 .95rem/1 'Space Grotesk', sans-serif;
  letter-spacing:.14em;
  color:#fff;
  background:linear-gradient(145deg, #10231f, #28443d);
  border:1px solid rgba(16,35,31,.08);
  box-shadow:0 14px 32px rgba(16,35,31,.16);
}

.brand-mark--compact{
  width:52px;
  height:52px;
  border-radius:16px;
  flex:none;
}

.eyebrow{
  margin:2px 0 4px;
  color:rgba(12,20,18,.58);
  text-transform:uppercase;
  letter-spacing:.14em;
  font-size:.72rem;
  font-weight:700;
}

.lede{
  margin:2px 0 0;
  max-width:64ch;
  color:var(--muted);
  font-size:.94rem;
  line-height:1.35;
}

.btn{
  appearance:none;
  border:none;
  cursor:pointer;
  border-radius:999px;
  padding:11px 15px;
  font-weight:700;
  transition:transform .18s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}
.btn:hover{ transform:translateY(-1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; transform:none; }
.btn--ghost{
  background:#fff;
  border:1px solid rgba(15,23,32,.08);
  color:var(--text);
  box-shadow:var(--shadow-soft);
}
.btn--ghost:hover{ background:var(--surface); }
.btn--primary{
  background:linear-gradient(135deg, var(--green), var(--green-strong));
  color:#fff;
  box-shadow:0 12px 28px rgba(31,122,87,.28);
}
.btn--soft{
  background:#f7f1df;
  color:#173128;
  border:1px solid rgba(23,49,40,.12);
}

.metrics{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:14px;
  margin:16px 0;
}

.metrics[hidden],
.brand-copy[hidden],
.admin-overview[hidden]{
  display:none !important;
}

.metric-card{
  border:1px solid var(--border);
  border-radius:24px;
  background:var(--card);
  box-shadow:var(--shadow);
  padding:18px;
  min-height:112px;
}
.metric-label{
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.12em;
  font-size:.72rem;
  font-weight:700;
}
.metric-value{
  margin-top:12px;
  font:700 clamp(1.4rem, 3vw, 2rem)/1.05 'Space Grotesk', sans-serif;
}
.metric-value--small{
  font-size:1rem;
  line-height:1.45;
}

.top-strip{
  position:sticky;
  top:14px;
  z-index:8;
  display:grid;
  grid-template-columns:auto minmax(0, 1fr) auto;
  align-items:center;
  gap:12px;
  padding:10px 12px;
  margin:0 0 16px;
  border-radius:26px;
  background:rgba(255,255,255,.76);
  backdrop-filter:blur(18px);
  border:1px solid rgba(15,23,32,.08);
  box-shadow:var(--shadow-soft);
}

.segmented{
  z-index:5;
  display:flex;
  gap:8px;
  padding:6px;
  border-radius:22px;
  background:rgba(16,35,31,.04);
  border:1px solid rgba(15,23,32,.06);
  min-width:0;
}
.segmented__btn{
  flex:1;
  border:none;
  background:transparent;
  border-radius:16px;
  padding:13px 12px;
  font-weight:700;
  color:rgba(12,20,18,.7);
  cursor:pointer;
}
.segmented__btn.active{
  background:#fff;
  color:#10231f;
  border:1px solid rgba(15,23,32,.06);
  box-shadow:var(--shadow-soft);
}

.quick-actions{
  display:flex;
  align-items:center;
  gap:8px;
}

.icon-btn{
  width:46px;
  height:46px;
  border:none;
  border-radius:16px;
  display:grid;
  place-items:center;
  cursor:pointer;
  color:#173128;
  background:rgba(16,35,31,.06);
  border:1px solid rgba(15,23,32,.08);
  box-shadow:var(--shadow-soft);
  transition:transform .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}

.icon-btn:hover{
  transform:translateY(-1px);
  background:rgba(16,35,31,.1);
}

.icon-btn--login{
  background:linear-gradient(145deg, rgba(255,255,255,.95), rgba(244,247,249,.92));
}

.icon-btn--soft{
  width:40px;
  height:40px;
  border-radius:14px;
  box-shadow:none;
}

.icon-btn__glyph{
  position:relative;
  display:block;
  width:18px;
  height:18px;
  color:currentColor;
}

.icon-btn--login .icon-btn__glyph::before{
  content:"";
  position:absolute;
  left:50%;
  top:1px;
  width:8px;
  height:8px;
  border-radius:999px;
  background:currentColor;
  transform:translateX(-50%);
}

.icon-btn--login .icon-btn__glyph::after{
  content:"";
  position:absolute;
  left:50%;
  bottom:1px;
  width:15px;
  height:9px;
  border-radius:10px 10px 7px 7px;
  border:2px solid currentColor;
  border-top:none;
  transform:translateX(-50%);
}

.icon-btn--menu .icon-btn__glyph,
.icon-btn__glyph--menu{
  width:18px;
  height:14px;
}

.icon-btn__glyph--menu::before,
.icon-btn__glyph--menu::after{
  content:"";
  position:absolute;
  left:0;
  width:18px;
  height:2px;
  border-radius:999px;
  background:currentColor;
  box-shadow:0 6px 0 currentColor;
}

.icon-btn__glyph--menu::before{
  top:0;
}

.icon-btn__glyph--menu::after{
  top:12px;
  width:11px;
  box-shadow:none;
}

.workspace{
  display:grid;
  gap:18px;
}

.admin-overview{
  display:grid;
  gap:6px;
  margin:16px 0 0;
  padding:0;
}

.admin-overview__copy{
  border:1px solid var(--border);
  border-radius:26px;
  background:linear-gradient(135deg, rgba(255,255,255,.92), rgba(247,248,251,.9));
  box-shadow:var(--shadow);
  padding:22px 24px;
}

.drawer-backdrop{
  position:fixed;
  inset:0;
  background:rgba(12,20,18,.18);
  backdrop-filter:blur(3px);
  z-index:30;
  opacity:0;
  pointer-events:none;
  transition:opacity .22s ease;
}

.summary-drawer{
  position:fixed;
  top:14px;
  right:14px;
  z-index:31;
  width:min(360px, calc(100vw - 28px));
  max-height:calc(100vh - 28px);
  overflow:auto;
  padding:18px;
  background:rgba(255,255,255,.96);
  border:1px solid var(--border);
  border-radius:28px;
  box-shadow:-24px 20px 60px rgba(15,23,32,.14);
  transform:translateX(calc(100% + 26px));
  opacity:0;
  pointer-events:none;
  transition:transform .24s ease, opacity .2s ease;
}

.summary-drawer__head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:12px;
}

.summary-drawer__head h2{
  margin:0;
  font:700 1.35rem/1.1 'Space Grotesk', sans-serif;
}

.menu-links{
  display:grid;
  gap:8px;
  margin:14px 0 16px;
}

.menu-link{
  display:flex;
  align-items:center;
  width:100%;
  border:none;
  border-radius:18px;
  padding:13px 15px;
  background:rgba(16,35,31,.045);
  border:1px solid rgba(15,23,32,.06);
  color:#173128;
  font-weight:700;
  cursor:pointer;
  transition:background .18s ease, transform .18s ease;
}

.menu-link:hover{
  background:rgba(16,35,31,.08);
  transform:translateY(-1px);
}

.summary-drawer .metrics{
  grid-template-columns:1fr;
  margin:12px 0 0;
}

.summary-drawer .admin-overview{
  margin:0 0 12px;
}

.summary-drawer .admin-overview__copy{
  padding:16px;
  border-radius:20px;
  box-shadow:var(--shadow-soft);
}

.summary-drawer__footer{
  margin-top:18px;
  padding-top:16px;
  border-top:1px solid rgba(15,23,32,.08);
}

.btn--wide{
  width:100%;
  justify-content:center;
  text-align:center;
}

body.summary-open{
  overflow:hidden;
}

body.summary-open .drawer-backdrop{
  opacity:1;
  pointer-events:auto;
}

body.summary-open .summary-drawer{
  transform:translateX(0);
  opacity:1;
  pointer-events:auto;
}

.panel{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:30px;
  box-shadow:var(--shadow);
  padding:22px;
}

.panel--expense{
  background:
    radial-gradient(circle at top right, rgba(31,122,87,.06), transparent 24%),
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(250,248,243,.96));
}

.panel-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:14px;
}

.panel-head__compact{
  width:100%;
  display:grid;
  gap:12px;
}

.panel-kicker{
  margin:0 0 6px;
  color:var(--green);
  text-transform:uppercase;
  letter-spacing:.12em;
  font-size:.72rem;
  font-weight:700;
}
.panel h2{
  margin:0;
  font:700 clamp(1.35rem, 3vw, 1.92rem)/1.05 'Space Grotesk', sans-serif;
}
.panel-copy{
  margin:0 0 18px;
  color:var(--muted);
  line-height:1.6;
}

.panel-copy--tight{
  margin:6px 0 0;
}

.expense-toolbar{
  display:grid;
  grid-template-columns:minmax(0, 1fr) auto;
  gap:12px;
  align-items:end;
}

.expense-toolbar__field{
  min-width:0;
}

.box-context{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:0 0 16px;
}

.box-context__pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:9px 12px;
  border-radius:999px;
  background:rgba(16,35,31,.05);
  border:1px solid rgba(16,35,31,.08);
  color:#173128;
  font-size:.84rem;
  font-weight:700;
}

body.is-operator .workspace{
  gap:14px;
}

body.is-operator .panel{
  padding:18px;
}

body.is-operator .panel-copy.is-empty{
  padding:12px 14px;
  border-radius:16px;
  background:rgba(200,140,58,.1);
  border:1px solid rgba(200,140,58,.18);
  color:#6a4a17;
}

.balance-chip{
  flex-shrink:0;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:4px;
  padding:14px 16px;
  border-radius:20px;
  background:linear-gradient(135deg, rgba(31,122,87,.08), rgba(200,140,58,.1));
  border:1px solid rgba(31,122,87,.12);
}
.balance-chip span{
  color:var(--muted);
  font-size:.76rem;
  text-transform:uppercase;
  letter-spacing:.12em;
}
.balance-chip strong{
  font:700 1.45rem/1 'Space Grotesk', sans-serif;
}

.form-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:14px;
}

.field{ display:flex; flex-direction:column; gap:8px; }
.field--full{ grid-column:1 / -1; }
.field--inline{ min-width:min(280px, 100%); }

.field label{
  color:var(--muted);
  font-size:.82rem;
  font-weight:700;
  letter-spacing:.02em;
}

.field-check{
  display:flex;
  align-items:center;
  gap:10px;
  font-size:.92rem;
  font-weight:700;
  color:var(--text);
}

.field-check input{
  width:20px;
  height:20px;
  flex:none;
  margin:0;
  appearance:none;
  border:1.5px solid rgba(16,35,31,.24);
  border-radius:6px;
  background:#fff;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.22);
  transition:border-color .16s ease, background-color .16s ease, box-shadow .16s ease, transform .16s ease;
  cursor:pointer;
}

.field-check input:hover{
  border-color:rgba(31,122,87,.42);
}

.field-check input:checked{
  background:var(--green);
  border-color:var(--green);
  box-shadow:0 0 0 3px rgba(31,122,87,.14);
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.2' d='M3 7.4 5.6 10 11 4.6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:center;
  background-size:13px 13px;
}

.field-check input:disabled{
  cursor:not-allowed;
  opacity:.6;
}

.period-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:12px;
}

.preview-note{
  border:1px dashed rgba(16,35,31,.12);
  border-radius:18px;
  padding:13px 14px;
  background:rgba(16,35,31,.025);
  color:var(--muted);
  line-height:1.45;
}

.period-card{
  border:1px solid rgba(16,35,31,.08);
  border-radius:20px;
  background:rgba(247,248,251,.72);
  padding:14px;
}

.period-card.is-disabled{
  opacity:1;
}

.period-card select:disabled{
  background:#eef1f4;
  color:rgba(12,20,18,.52);
  border-color:rgba(15,23,32,.08);
}

.period-card.is-disabled select:disabled{
  background:#edf0f3;
  color:rgba(12,20,18,.48);
}

.period-card.is-accounting-off select#expense_exercise_id:disabled{
  background:#f3f4f6;
  color:rgba(12,20,18,.42);
}

input, select, textarea{
  width:100%;
  border-radius:16px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  font-size:16px;
  padding:13px 14px;
  box-shadow:0 1px 0 rgba(255,255,255,.85) inset;
}
input:focus, select:focus, textarea:focus{
  outline:none;
  border-color:rgba(31,122,87,.28);
  box-shadow:0 0 0 4px rgba(31,122,87,.08);
}
input:disabled, select:disabled, textarea:disabled{
  background:rgba(16,35,31,.04);
  color:rgba(12,20,18,.58);
  cursor:not-allowed;
  opacity:.78;
}
textarea{
  min-height:96px;
  resize:vertical;
}

.actions-row{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:10px;
  margin-top:16px;
}

.list{
  display:grid;
  gap:12px;
}

.movement{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  padding:16px;
  border:1px solid var(--border);
  border-radius:22px;
  background:linear-gradient(180deg, rgba(255,255,255,.98), rgba(247,248,251,.96));
  box-shadow:var(--shadow-soft);
}
.movement__main{ min-width:0; }
.movement__head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}
.movement__title{
  font-weight:700;
  font-size:1rem;
  margin-bottom:3px;
}
.movement__meta,
.movement__sub{
  color:var(--muted);
  font-size:.88rem;
  line-height:1.4;
}
.movement__amount{
  flex-shrink:0;
  font:700 1.2rem/1 'Space Grotesk', sans-serif;
}
.movement__amount.is-in{ color:var(--green); }
.movement__amount.is-out{ color:#9a3c2a; }

.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 10px;
  border-radius:999px;
  font-size:.72rem;
  font-weight:700;
  letter-spacing:.08em;
  text-transform:uppercase;
}
.badge--in{ background:rgba(31,122,87,.12); color:var(--green-strong); }
.badge--out{ background:rgba(154,60,42,.12); color:#9a3c2a; }

.balances-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:14px;
}
.balance-card{
  border:1px solid var(--border);
  border-radius:24px;
  background:linear-gradient(180deg, rgba(255,255,255,.98), rgba(247,248,251,.96));
  padding:18px;
  box-shadow:var(--shadow-soft);
}
.balance-card__top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
}
.balance-card__name{
  font-weight:700;
  font-size:1rem;
}
.balance-card__code{
  color:var(--muted);
  font-size:.88rem;
  margin-top:4px;
}
.balance-card__amount{
  font:700 1.2rem/1 'Space Grotesk', sans-serif;
  color:var(--green-strong);
}

.empty{
  border:1px dashed rgba(16,35,31,.16);
  border-radius:22px;
  padding:20px;
  background:rgba(255,255,255,.7);
}
.empty__title{
  font-weight:700;
  margin-bottom:6px;
}
.empty__copy{
  color:var(--muted);
  line-height:1.55;
}

.footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-top:16px;
  padding:8px 4px 0;
  color:rgba(12,20,18,.72);
  font-size:.9rem;
}

.toast{
  position:fixed;
  left:50%;
  bottom:18px;
  transform:translateX(-50%) translateY(12px);
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease, transform .18s ease;
  background:#10231f;
  color:#fff;
  padding:14px 16px;
  border-radius:999px;
  color:#fff;
  box-shadow:0 18px 40px rgba(4,12,10,.22);
  z-index:20;
}
.toast.show{
  opacity:1;
  transform:translateX(-50%) translateY(0);
}

@media (max-width: 980px){
  .app-shell{ width:min(100vw - 16px, 1200px); padding-top:8px; }
  .metrics{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .form-grid, .balances-grid{ grid-template-columns:1fr; }
  .period-grid{ grid-template-columns:1fr; }
  .panel-head, .movement__head, .balance-card__top{ flex-direction:column; }
  .movement{ flex-direction:column; }
  .movement__amount{ align-self:flex-end; }
  .top-strip{ top:8px; }
  .segmented__btn{ padding:13px 10px; }
  .footer{ flex-direction:column; align-items:flex-start; color:rgba(12,20,18,.75); }
}

@media (max-width: 640px){
  .app-shell{ width:min(100vw - 12px, 1200px); }
  .top-strip{
    grid-template-columns:auto auto;
    gap:10px;
    align-items:start;
  }
  .top-strip .segmented{
    grid-column:1 / -1;
    order:3;
  }
  .metrics{ grid-template-columns:1fr; }
  .segmented{
    overflow:auto;
    -webkit-overflow-scrolling:touch;
  }
  .segmented__btn{
    min-width:150px;
    white-space:nowrap;
  }
  .panel{
    padding:16px;
    border-radius:24px;
  }
  .balance-chip{
    width:100%;
    align-items:flex-start;
  }
  .expense-toolbar{
    grid-template-columns:1fr;
    align-items:stretch;
  }
  .movement{
    padding:14px;
  }
}

body[data-device="mobile"]{
  background:
    radial-gradient(circle at top left, rgba(31,122,87,.12), transparent 42%),
    radial-gradient(circle at top right, rgba(200,140,58,.14), transparent 34%),
    linear-gradient(180deg, #eef3f8 0%, #f5f3ed 100%);
}

body[data-device="mobile"] .app-shell{
  width:min(100vw - 12px, 1200px);
  padding-top:10px;
  padding-bottom:24px;
}

body[data-device="mobile"] .brand-mark{
  width:48px;
  height:48px;
  border-radius:15px;
}

body[data-device="mobile"] .top-strip{
  top:8px;
  grid-template-columns:auto auto;
  gap:10px;
  padding:10px;
}

body[data-device="mobile"] .top-strip .segmented{
  grid-column:1 / -1;
  order:3;
}

body[data-device="mobile"] .quick-actions{
  justify-self:end;
}

body[data-device="mobile"] .metrics{
  grid-template-columns:1fr;
  gap:10px;
}

body[data-device="mobile"] .metric-card{
  min-height:auto;
  padding:16px;
}

body[data-device="mobile"] .segmented{
  top:8px;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:none;
}

body[data-device="mobile"] .segmented::-webkit-scrollbar{
  display:none;
}

body[data-device="mobile"] .segmented__btn{
  min-width:148px;
  white-space:nowrap;
}

body[data-device="mobile"] .workspace{
  gap:14px;
}

body[data-device="mobile"] .panel{
  padding:16px;
  border-radius:24px;
}

body[data-device="mobile"] .panel-head,
body[data-device="mobile"] .movement,
body[data-device="mobile"] .movement__head,
body[data-device="mobile"] .balance-card__top{
  flex-direction:column;
}

body[data-device="mobile"] .balance-chip{
  width:100%;
  align-items:flex-start;
  padding:12px 14px;
}

body[data-device="mobile"] .expense-toolbar{
  grid-template-columns:1fr;
  align-items:stretch;
}

body[data-device="mobile"] .form-grid,
body[data-device="mobile"] .balances-grid,
body[data-device="mobile"] .period-grid{
  grid-template-columns:1fr;
}

body[data-device="mobile"] .field--inline{
  min-width:100%;
}

body[data-device="mobile"] .actions-row{
  flex-direction:column;
  align-items:stretch;
}

body[data-device="mobile"] .actions-row .btn,
body[data-device="mobile"] .actions-row a.btn{
  width:100%;
  text-align:center;
  justify-content:center;
}

body[data-device="mobile"] .movement{
  padding:14px;
}

body[data-device="mobile"] .movement__amount{
  align-self:flex-start;
}

body[data-device="mobile"] .footer{
  flex-direction:column;
  align-items:flex-start;
  gap:6px;
}

body[data-device="mobile"] .summary-drawer{
  top:8px;
  right:8px;
  width:min(340px, calc(100vw - 16px));
  max-height:calc(100vh - 16px);
  padding:14px;
  border-radius:24px;
}
