:root {
  --ink: #102236;
  --muted: #5f6f82;
  --line: #d7e0ea;
  --panel: #ffffff;
  --soft: #f4f8fb;
  --blue: #0b67b2;
  --blue-dark: #07487f;
  --red: #cf1f2c;
  --green: #14744c;
  --amber: #c76f00;
  --shadow: 0 16px 44px rgba(16, 34, 54, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eaf1f7;
  font-family: "Segoe UI", Arial, sans-serif;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(120deg, #063c74 0%, #0b67b2 52%, #d92534 100%);
}

.login-card {
  width: min(460px, 100%);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 108px !important;
  max-width: 108px !important;
  height: 108px !important;
  max-height: 108px !important;
  object-fit: contain;
  display: block;
  margin-bottom: 16px;
}

.login-card h1 {
  margin: 4px 0 6px;
  font-size: 34px;
  color: var(--blue-dark);
  letter-spacing: 0;
}

.login-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-weight: 700;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  color: #fff;
  background: linear-gradient(100deg, #063c74 0%, #0b67b2 50%, #d92534 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  width: 122px;
  height: 122px;
  object-fit: contain;
  object-position: center;
  border: 2px solid rgba(255, 255, 255, 0.46);
  border-radius: 999px;
  background: #fff;
}

.brand-title {
  display: grid;
  gap: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 44px;
  line-height: 1.12;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}

.subhead {
  margin: 0;
  max-width: 760px;
  font-size: 20px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.86);
}

.header-machine-count {
  display: grid;
  align-content: center;
  min-width: 360px;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
}

.session-actions {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 10px !important;
  padding-top: 6px;
}

.session-actions span {
  font-size: 12px;
  font-weight: 900;
}

.session-actions .ghost-button {
  min-height: 32px;
  padding: 6px 10px;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.12);
}

.header-machine-count div {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.header-machine-count span {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.header-machine-count strong {
  font-size: 14px;
  white-space: nowrap;
}

.quick-rate {
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 220px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 32px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-width: 120px;
  padding: 12px 18px;
  color: var(--muted);
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  font-weight: 700;
}

.tab.is-active {
  color: var(--blue-dark);
  border-color: var(--blue);
}

main {
  padding: 24px 32px 36px;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(440px, 1.08fr) minmax(380px, 0.92fr);
  gap: 20px;
}

.management-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 20px;
}

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

.wide-panel {
  grid-column: 1 / -1;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin: 2px 0 0;
  font-size: 24px;
  letter-spacing: 0;
}

.result-panel .panel-heading h2 {
  font-size: 38px;
}

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

.form-grid.compact {
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.wide-field {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  min-width: 0;
  width: 100%;
  padding: 9px 11px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  outline: none;
}

input,
select {
  height: 42px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(11, 103, 178, 0.14);
}

.primary-button,
.ghost-button,
.danger-button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  color: #fff;
  background: var(--blue);
}

.primary-button:hover {
  background: var(--blue-dark);
}

.ghost-button,
.file-button {
  color: var(--blue-dark);
  border-color: var(--line);
  background: var(--soft);
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.full-button {
  width: 100%;
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

.required {
  color: var(--red);
}

.section-line {
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.file-button input {
  display: none;
}

.profit-pill {
  min-width: 132px;
  padding: 10px 12px;
  color: #fff;
  border-radius: 999px;
  background: var(--green);
  text-align: center;
  font-weight: 900;
}

.profit-pill.loss {
  background: var(--red);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-grid div {
  min-height: 82px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.summary-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-grid strong {
  font-size: 22px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  text-transform: uppercase;
}

.breakdown td:last-child,
.breakdown th:last-child {
  text-align: right;
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap table th,
.table-wrap table td {
  white-space: nowrap;
}

.paper-table {
  max-height: 320px;
  margin-top: 16px;
}

.search-results {
  display: grid;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.search-results button {
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 700;
}

.search-results button:hover {
  background: var(--soft);
}

.row-actions {
  display: flex;
  gap: 8px;
}

.mini-button {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--blue-dark);
  background: #fff;
  font-weight: 800;
}

.danger-mini {
  color: var(--red);
}

.payment-box {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.inline-check input {
  width: 18px;
  height: 18px;
}

.totals-list {
  display: grid;
  gap: 8px;
}

.totals-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.discount-row {
  align-items: center;
}

.discount-controls {
  display: grid;
  grid-template-columns: 170px 130px minmax(96px, auto);
  align-items: center;
  gap: 8px;
}

.discount-controls select,
.discount-controls input {
  height: 44px;
  padding-top: 8px;
  padding-bottom: 8px;
  line-height: 1.2;
}

.totals-list div:last-child {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 20px;
}

.date-filter {
  min-width: 180px;
}

.machine-count-card {
  display: grid;
  grid-template-columns: auto minmax(220px, auto);
  align-items: center;
  gap: 5px 10px;
  min-width: 360px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.machine-count-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.machine-count-card strong {
  font-size: 14px;
  white-space: nowrap;
}

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

.banking-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.note-box {
  margin-top: 14px;
}

.mini-line {
  margin: 7px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.subsection-title {
  margin: 20px 0 10px;
  font-size: 18px;
}

.product-profit-table {
  max-height: 280px;
}

.login-panel {
  max-width: 620px;
}

.customer-only .panel-heading h2 {
  color: var(--blue-dark);
}

small {
  color: var(--muted);
}

.rate-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.rate-slab-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.rate-slab-editor h3 {
  margin: 0;
  font-size: 16px;
}

.notes {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.note {
  padding: 9px 11px;
  border-left: 4px solid var(--amber);
  background: #fff8ec;
}

.error-note {
  border-left-color: var(--red);
  background: #fff0f1;
}

.success-note {
  border-left-color: var(--green);
  background: #edf9f3;
}

@media (max-width: 1060px) {
  .topbar,
  .brand {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .quick-rate {
    width: 100%;
  }

  .header-machine-count {
    width: 100%;
    min-width: 0;
  }

  .work-grid,
  .management-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  main,
  .tabs {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-logo {
    width: 112px;
    height: 112px;
  }

  .brand h1 {
    font-size: 34px;
  }

  .subhead {
    font-size: 17px;
  }

  .tabs {
    overflow-x: auto;
  }

  .form-grid,
  .summary-grid,
  .rate-editor,
  .rate-slab-editor,
  .denomination-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .machine-count-card {
    grid-template-columns: 1fr;
    min-width: 0;
    width: 100%;
  }

  .panel {
    padding: 16px;
  }
}
