:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17231d;
  background: #f3f6f3;
  font-synthesis: none;
  --green-900: #173f2c;
  --green-700: #276345;
  --green-100: #e1eee5;
  --line: #dce4de;
  --muted: #66736b;
  --white: #ffffff;
  --danger: #a23b3b;
  --shadow: 0 12px 35px rgba(29, 55, 41, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 900px; min-height: 100vh; background: linear-gradient(180deg, #edf3ee 0, #f7f8f7 380px); }
button, input, textarea { font: inherit; }
button, label.button { user-select: none; }

.app-shell { max-width: 1500px; margin: 0 auto; padding: 28px 34px 50px; }
.topbar, .statusbar, .section-heading, .toolbar, .dialog-heading, .dialog-actions, .inline-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: -0.03em; }
.topbar h1 small { color: var(--muted); font-size: 12px; letter-spacing: 0; }
.eyebrow { margin: 0; color: var(--green-700); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 750; }
.file-actions, .inline-actions { display: flex; gap: 9px; }
.database-indicator { display: flex; align-items: center; gap: 10px; padding: 9px 13px; border: 1px solid #cbe0d1; border-radius: 10px; background: rgba(255,255,255,.8); }
.database-indicator strong, .database-indicator small { display: block; }
.database-indicator strong { font-size: 13px; color: var(--green-900); }
.database-indicator small { margin-top: 1px; font-size: 11px; color: var(--muted); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #2c9a5f; box-shadow: 0 0 0 4px rgba(44,154,95,.12); }
.statusbar { margin: 22px 0 18px; padding: 10px 14px; border: 1px solid var(--line); background: rgba(255,255,255,.72); border-radius: 10px; color: var(--muted); font-size: 13px; }
.statusbar span:first-child { color: var(--green-900); font-weight: 700; }
.workflow-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 17px 19px; }
.workflow-toolbar h2 { margin: 2px 0 0; font-size: 17px; }
.workflow-actions { display: flex; align-items: center; gap: 9px; }

.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; padding: 10px 15px; cursor: pointer; font-weight: 700; text-decoration: none; transition: .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.button.disabled { cursor: not-allowed; opacity: .48; pointer-events: none; }
.count-badge { min-width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; margin-left: 5px; padding: 0 6px; border-radius: 999px; background: #b33e3e; color: white; font-size: 11px; }
.button.primary { background: var(--green-900); color: white; box-shadow: 0 5px 14px rgba(23,63,44,.18); }
.button.accent { background: var(--green-100); border-color: #c4ddcb; color: var(--green-900); }
.button.ghost { background: white; border-color: var(--line); color: #354139; }
.button.danger { background: #fff7f7; color: var(--danger); border-color: #ecd4d4; }
.button.small { padding: 7px 10px; font-size: 12px; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; padding: 0 0 2px; background: var(--green-900); color: white; font-size: 23px; line-height: 1; cursor: pointer; }

.workspace { display: grid; grid-template-columns: 270px 1fr; gap: 18px; min-height: 570px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.sidebar { padding: 20px 15px; }
.section-heading h2, .toolbar h3 { margin: 2px 0 0; }
.semester-list { margin-top: 18px; display: grid; gap: 7px; }
.semester-item { width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 9px; padding: 11px 12px; cursor: pointer; color: #344038; }
.semester-item:hover { background: #f4f7f4; }
.semester-item.active { background: var(--green-100); color: var(--green-900); font-weight: 750; border-color: #cbe0d1; }
.content { padding: 26px; }
.empty-state { min-height: 510px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-state h2 { margin: 18px 0 6px; }
.empty-state p { color: var(--muted); max-width: 440px; margin: 0 0 22px; }
.empty-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: var(--green-100); color: var(--green-900); font-size: 35px; }
.database-gate { position: relative; min-height: 570px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 40px 72px; }
.database-gate h2 { margin: 18px 0 7px; }
.database-gate p { max-width: 540px; margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.database-gate-actions { display: flex; align-items: center; justify-content: center; }
.empty-database-button { position: absolute; bottom: 24px; border: 0; padding: 2px 4px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; transition: .15s ease; }
.empty-database-button:hover { color: var(--green-700); text-decoration-color: currentColor; }
.semester-title-row { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.toolbar { padding: 24px 0 16px; }
.toolbar h3 { font-size: 18px; }
.toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.practical-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.practical-card { border: 1px solid var(--line); border-radius: 12px; padding: 17px; cursor: pointer; background: #fff; transition: .15s ease; }
.practical-card:hover { border-color: #a9c6b3; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(23,63,44,.08); }
.practical-card h4 { margin: 0 0 14px; font-size: 16px; }
.practical-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.practical-stats.aggregate-stats { grid-template-columns: repeat(2, 1fr); }
.practical-stats div { background: #f5f7f5; border-radius: 8px; padding: 9px; }
.practical-stats strong { display: block; font-size: 14px; color: var(--green-900); }
.practical-stats span { font-size: 11px; color: var(--muted); }
.no-practicals { grid-column: 1/-1; padding: 45px; border: 1px dashed #cbd7ce; border-radius: 12px; text-align: center; color: var(--muted); }

dialog { width: min(510px, calc(100vw - 40px)); border: 0; border-radius: 16px; padding: 0; box-shadow: 0 25px 80px rgba(12,32,21,.28); }
dialog::backdrop { background: rgba(16,35,25,.42); backdrop-filter: blur(2px); }
dialog form, #details-content { padding: 24px; }
.dialog-heading { margin-bottom: 20px; }
.dialog-heading h2 { margin: 0; font-size: 21px; }
.close-button { border: 0; background: transparent; font-size: 25px; cursor: pointer; color: var(--muted); }
dialog label { display: grid; gap: 7px; margin: 14px 0; color: #37433b; font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #cdd8d0; border-radius: 9px; padding: 10px 11px; outline: none; background: #fbfcfb; }
input:focus, textarea:focus, select:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(39,99,69,.1); }
textarea { resize: vertical; }
.label-hint { color: var(--muted); font-weight: 400; float: right; }
.semester-fields { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; }
.semester-format-preview { margin: 8px 0 0; padding: 11px 12px; border-radius: 9px; background: #f4f7f4; color: var(--muted); font-size: 12px; line-height: 1.55; }
.semester-format-preview strong { color: var(--green-900); }
.dialog-actions { justify-content: flex-end; margin-top: 22px; }
.details-dialog { width: min(780px, calc(100vw - 40px)); }
.result-dialog { width: min(590px, calc(100vw - 40px)); }
.transactions-dialog { width: min(920px, calc(100vw - 40px)); }
.manual-assignment-dialog { width: min(760px, calc(100vw - 40px)); }
.dialog-panel { padding: 24px; }
.result-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0; }
.result-summary article { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #f7f9f7; }
.result-summary strong { display: block; color: var(--green-900); font-size: 22px; }
.result-summary span { color: var(--muted); font-size: 12px; }
.result-note { margin: 0; padding: 12px 14px; border-radius: 9px; background: #fff7e9; color: #765020; font-size: 13px; line-height: 1.45; }
.transaction-filters { display: flex; gap: 7px; margin: 18px 0 14px; }
.filter-button { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; background: white; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; }
.filter-button.active { border-color: var(--green-900); background: var(--green-900); color: white; }
.transactions-content { max-height: min(570px, 65vh); overflow: auto; display: grid; gap: 9px; padding-right: 3px; }
.transaction-item { display: grid; grid-template-columns: 105px 100px 1fr auto; gap: 12px; align-items: start; padding: 13px; border: 1px solid var(--line); border-radius: 10px; }
.transaction-item time, .transaction-item .amount { font-size: 13px; font-weight: 700; }
.transaction-item .amount { text-align: right; color: var(--green-900); }
.transaction-purpose { margin: 0; font-size: 13px; line-height: 1.4; }
.transaction-counterparty { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.transaction-reasons { grid-column: 2 / -1; margin: 0; padding-left: 17px; color: #8b3d3d; font-size: 12px; }
.badge.conflict { background: #fde5e5; color: #933b3b; }
.badge.assigned { background: var(--green-100); color: var(--green-900); }
.badge.resolved { background: #eceff1; color: #4e5b62; }
.transaction-actions { grid-column: 2 / -1; display: flex; justify-content: flex-end; }
.manual-transaction-summary { padding: 12px 14px; border-radius: 10px; background: #f3f6f3; font-size: 13px; line-height: 1.45; }
.manual-transaction-summary strong { display: block; margin-bottom: 3px; }
.manual-assignment-list { max-height: min(430px, 50vh); overflow: auto; margin-top: 15px; border: 1px solid var(--line); border-radius: 10px; }
.assignment-group h3 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 9px 12px; background: #edf3ee; color: var(--green-900); font-size: 12px; }
.assignment-option { display: grid; grid-template-columns: 24px 1fr 115px; gap: 9px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.assignment-option:first-of-type { border-top: 0; }
.assignment-option input[type="checkbox"] { width: 16px; height: 16px; }
.assignment-option input[type="number"] { padding: 8px 9px; text-align: right; }
.assignment-option-name { font-size: 13px; font-weight: 700; }
.assignment-option-meta { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 400; }
.form-error { margin: 11px 0 0; color: #9b3434; font-size: 12px; font-weight: 700; }
.manual-assignment-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.manual-assignment-footer span, .manual-assignment-footer strong { display: block; }
.manual-assignment-footer span { color: var(--muted); font-size: 11px; }
.manual-assignment-footer strong { color: var(--green-900); font-size: 18px; }
.manual-assignment-footer .dialog-actions { margin-top: 0; }
.dialog-description { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.detail-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.detail-metrics > div { padding: 12px; border-radius: 9px; background: #f5f7f5; }
.detail-metrics strong, .detail-metrics span { display: block; }
.detail-metrics strong { color: var(--green-900); font-size: 16px; }
.detail-metrics span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.warning-metric { background: #fff0dd !important; color: #88551d; }
.privacy-note, .review-notice { margin: 16px 0 0; padding: 12px 14px; border-radius: 9px; font-size: 13px; line-height: 1.45; }
.privacy-note { background: var(--green-100); color: var(--green-900); }
.review-notice { background: #fff0dd; color: #88551d; }
.review-flag { display: inline-flex; margin: -7px 0 12px; padding: 4px 8px; border-radius: 999px; background: #fff0dd; color: #88551d; font-size: 11px; font-weight: 750; }
.split-actions { flex-wrap: wrap; }
.anonymous-description { color: var(--muted); font-size: 13px; }
.people-table { width: 100%; border-collapse: collapse; margin-top: 18px; }
.person-adder { height: 40px; margin-top: 16px; align-items: center; gap: 9px; }
.person-adder[open] { display: flex; }
.person-adder summary { width: fit-content; height: 40px; flex: 0 0 auto; display: flex; align-items: center; margin: 0; padding: 0 13px; border-radius: 9px; background: var(--green-900); color: white; cursor: pointer; font-size: 13px; font-weight: 700; white-space: nowrap; list-style: none; }
.person-adder summary::-webkit-details-marker { display: none; }
.person-adder summary::before { content: "+"; margin-right: 7px; font-size: 16px; }
.person-adder[open] summary::before { content: "−"; }
.person-adder summary:focus-visible { outline: 3px solid rgba(39,99,69,.22); outline-offset: 2px; }
.add-person-form { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto; gap: 9px; align-items: center; flex: 1; padding: 0; }
.add-person-form input { min-width: 0; height: 40px; }
.add-person-actions { display: flex; justify-content: flex-end; gap: 8px; }
.add-person-actions .button { height: 40px; white-space: nowrap; }
.people-table th, .people-table td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; font-size: 13px; }
.people-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.sortable-header { margin: -6px -7px; padding: 6px 7px; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; font: inherit; font-weight: 700; letter-spacing: inherit; text-transform: inherit; }
.sortable-header:hover { background: var(--green-100); color: var(--green-900); }
.sortable-header:focus-visible { outline: 2px solid var(--green-700); outline-offset: 1px; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.badge.open { background: #fff0dd; color: #88551d; }
.badge.paid { background: var(--green-100); color: var(--green-900); }
.toast { position: fixed; right: 28px; bottom: 28px; background: #17231d; color: white; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.site-footer { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px 9px; padding: 24px 12px 0; color: var(--muted); font-size: 11px; text-align: center; }
.site-footer a { color: var(--green-700); font-weight: 700; text-underline-offset: 3px; }
.site-footer a:hover { color: var(--green-900); }
.footer-separator { color: #9caaa1; font-size: 9px; }

@media (max-width: 1050px) {
  .practical-grid { grid-template-columns: 1fr; }
}
