:root {
    --ink: #18202a;
    --muted: #697386;
    --line: #dce4ea;
    --paper: #ffffff;
    --wash: #f4f7f8;
    --teal: #117c7a;
    --teal-dark: #0d5f5d;
    --mint: #dff5ef;
    --coral: #ee6b4d;
    --amber: #f4b740;
    --green: #2f9b64;
    --danger: #c0392b;
    --shadow: 0 18px 45px rgba(24, 32, 42, .11);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 84% 8%, rgba(244, 183, 64, .16), transparent 34%),
        linear-gradient(135deg, #f7faf9 0%, #edf4f1 48%, #f8f2ef 100%);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

textarea {
    min-height: 86px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(17, 124, 122, .15);
}

label {
    display: grid;
    gap: 7px;
    color: #354153;
    font-size: 13px;
    font-weight: 700;
}

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 10px;
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

th {
    color: #516071;
    font-size: 12px;
    text-transform: uppercase;
    background: #f7faf9;
    letter-spacing: 0;
}

.auth-page {
    background:
        linear-gradient(150deg, rgba(17, 124, 122, .92), rgba(24, 32, 42, .86)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cpath d='M20 35h140M20 90h140M20 145h140M35 20v140M90 20v140M145 20v140' stroke='%23ffffff' stroke-opacity='.15' stroke-width='8'/%3E%3C/svg%3E");
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(430px, 100%);
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(255, 255, 255, .68);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 30px;
    animation: rise .45s ease both;
}

.auth-card h1,
.topbar h1,
.panel h2 {
    margin: 0;
}

.auth-card p {
    color: var(--muted);
    line-height: 1.55;
}

.brand-mark,
.side-brand span {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--teal), var(--green));
    color: #fff;
    font-weight: 900;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    padding: 20px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(16px);
    border-right: 1px solid rgba(220, 228, 234, .86);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 20;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
}

.sidebar nav {
    display: grid;
    gap: 7px;
}

.sidebar nav a {
    padding: 12px 13px;
    border-radius: 8px;
    color: #445164;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-icon {
    width: 34px;
    min-width: 34px;
    height: 30px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #eef5f3;
    color: var(--teal-dark);
    font-size: 11px;
    font-weight: 950;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: var(--mint);
    color: var(--teal-dark);
    transform: translateX(3px);
}

.sidebar nav a:hover .nav-icon,
.sidebar nav a.active .nav-icon {
    background: var(--teal);
    color: #fff;
}

.app {
    min-height: 100vh;
    margin-left: 250px;
    padding: 28px;
}

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

.eyebrow {
    margin: 0 0 4px;
    color: var(--coral);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.user-chip,
.available-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    padding: 8px 12px;
    color: #465569;
    font-weight: 800;
    white-space: nowrap;
}

.balance-chip {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    min-height: 42px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #465569;
    font-weight: 900;
}

.balance-chip strong {
    color: var(--teal-dark);
}

.panel {
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(220, 228, 234, .92);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(24, 32, 42, .07);
    padding: 18px;
    margin-bottom: 20px;
    animation: rise .34s ease both;
}

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

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

.btn,
.icon-btn {
    border: 0;
    border-radius: 8px;
    min-height: 42px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 900;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.btn:hover,
.icon-btn:hover {
    transform: translateY(-1px);
}

.btn.primary {
    color: #fff;
    background: linear-gradient(135deg, var(--teal), var(--green));
    box-shadow: 0 12px 22px rgba(17, 124, 122, .2);
}

.btn.secondary {
    color: var(--teal-dark);
    background: var(--mint);
}

.btn.ghost {
    color: #48566a;
    background: #f0f4f5;
}

.btn.mini {
    min-height: 34px;
    padding: 7px 10px;
    background: #eef5f3;
    color: var(--teal-dark);
}

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

.full {
    width: 100%;
}

.icon-btn {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    color: var(--teal-dark);
    background: #e9f5f2;
    font-size: 20px;
}

.icon-btn.danger {
    color: #fff;
    background: var(--danger);
}

.notice {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 800;
}

.notice.success {
    background: #def4e6;
    color: #17603d;
}

.notice.danger {
    background: #ffe5df;
    color: #9b2d1f;
}

.stack {
    display: grid;
    gap: 14px;
}

.floor-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.floor-button {
    min-height: 168px;
    border: 1px solid rgba(17, 124, 122, .2);
    border-radius: 8px;
    padding: 22px;
    display: grid;
    align-content: space-between;
    background: linear-gradient(135deg, #ffffff 0%, #e6f5f2 100%);
    box-shadow: var(--shadow);
    transition: transform .18s ease, border-color .18s ease;
}

.floor-button:hover,
.floor-button.active {
    transform: translateY(-4px);
    border-color: var(--teal);
}

.floor-button span {
    color: var(--muted);
    font-weight: 800;
}

.floor-button strong {
    font-size: clamp(58px, 8vw, 96px);
    line-height: .9;
    color: var(--teal-dark);
}

.floor-button em {
    color: var(--coral);
    font-style: normal;
    font-weight: 800;
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(86px, 1fr));
    gap: 10px;
}

.room-button {
    min-height: 84px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    display: grid;
    place-items: center;
    gap: 4px;
    transition: transform .16s ease, border-color .16s ease;
}

.room-button strong {
    font-size: 25px;
}

.room-button span {
    color: var(--muted);
    font-weight: 800;
}

.room-button:hover,
.room-button.active {
    border-color: var(--coral);
    transform: translateY(-2px);
}

.chamber-tables {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.chamber-table {
    display: grid;
    gap: 12px;
    padding: 12px;
    border: 1px dashed #c9d6dc;
    border-radius: 8px;
    background: #f8fbfa;
}

.chamber-side-title {
    color: var(--teal-dark);
    font-size: 15px;
    font-weight: 950;
}

.chamber-row {
    display: grid;
    grid-template-columns: 62px repeat(10, minmax(66px, 1fr));
    gap: 8px;
    align-items: stretch;
}

.level-label {
    min-height: 86px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 12px;
    font-weight: 950;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0;
}

.up-row .level-label {
    background: var(--teal-dark);
}

.down-row .level-label {
    background: var(--coral);
}

.chamber-cell {
    min-height: 86px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    display: grid;
    gap: 4px;
    place-items: center;
    padding: 8px;
    color: var(--ink);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.up-cell {
    border-top: 5px solid var(--teal);
    background: linear-gradient(180deg, #f1fbf8 0%, #fff 60%);
}

.down-cell {
    border-bottom: 5px solid var(--coral);
    background: linear-gradient(0deg, #fff3ef 0%, #fff 60%);
}

.chamber-cell.full-cell {
    border-color: #d43f31;
    background: linear-gradient(180deg, #ff6b57 0%, #d83a2e 100%);
    color: #fff;
}

.chamber-cell.full-cell .chamber-no,
.chamber-cell.full-cell strong {
    color: #fff;
}

.chamber-cell.full-cell strong {
    background: rgba(255, 255, 255, .22);
}

.chamber-cell:hover {
    border-color: var(--teal);
}

.chamber-no {
    font-size: 23px;
    font-weight: 950;
    color: var(--teal-dark);
}

.chamber-cell small {
    color: var(--coral);
    font-weight: 900;
}

.chamber-cell strong {
    background: #ecf7f1;
    color: #17603d;
    border-radius: 999px;
    padding: 2px 9px;
}

.chamber-cell em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
}

.two-col,
.three-col,
.report-grid,
.statement-grid {
    display: grid;
    gap: 18px;
}

.two-col {
    grid-template-columns: minmax(280px, 390px) 1fr;
}

.statement-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
}

.statement-grid .panel {
    margin-bottom: 0;
}

.three-col {
    grid-template-columns: minmax(260px, 340px) minmax(240px, 320px) 1fr;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.data-table-wrap {
    display: grid;
    gap: 12px;
}

.data-table-tools {
    display: flex;
    align-items: end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.data-table-tools label {
    min-width: 180px;
}

.data-table-tools input,
.data-table-tools select {
    min-height: 36px;
}

.data-table-count {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf9;
    min-height: 36px;
    padding: 8px 11px;
    display: inline-flex;
    align-items: center;
    color: #516071;
    font-weight: 900;
}

.data-table-pager {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.data-table-pager span {
    color: #516071;
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
}

.data-table-pager button:disabled {
    cursor: not-allowed;
    opacity: .45;
    transform: none;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.data-table th.sortable::after {
    content: "sort";
    margin-left: 6px;
    color: #9aa6b2;
    font-size: 11px;
}

.data-table th[aria-sort="ascending"]::after {
    content: "^";
    color: var(--teal-dark);
}

.data-table th[aria-sort="descending"]::after {
    content: "v";
    color: var(--teal-dark);
}

.entry-table {
    min-width: 1480px;
}

.entry-table input,
.entry-table select {
    min-width: 92px;
}

.entry-table td {
    padding: 8px;
}

.entry-totals {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
    margin-top: 12px;
}

.entry-totals span {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf9;
    padding: 10px 14px;
    font-weight: 900;
}

.entry-totals strong {
    color: var(--teal-dark);
}

.ledger-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.ledger-summary span {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf9;
    padding: 12px 14px;
    color: #516071;
    font-weight: 900;
}

.ledger-summary strong {
    display: block;
    color: var(--teal-dark);
    font-size: 18px;
    margin-top: 4px;
}

.tiny-input {
    max-width: 84px;
}

.chamber-select {
    min-width: 132px;
    max-width: 150px;
}

.chamber-select option {
    color: var(--ink);
    font-weight: 400;
}

.chamber-select option.has-stock {
    color: var(--danger);
    font-weight: 900;
}

.chamber-select.chamber-has-stock {
    font-weight: 900;
}

.check-grid,
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.check-grid label,
.tag-list span {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    padding: 8px 11px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.check-grid input {
    width: auto;
    min-height: auto;
}

input[readonly] {
    background: #f4f7f7;
    color: #687589;
    cursor: not-allowed;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(24, 32, 42, .46);
    display: none;
    place-items: center;
    padding: 18px;
    z-index: 50;
}

.modal.open {
    display: grid;
}

.modal-card {
    width: min(580px, 100%);
    background: #fff;
    border-radius: 8px;
    padding: 22px;
    box-shadow: var(--shadow);
    position: relative;
    animation: rise .22s ease both;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: #f0f4f5;
    font-size: 24px;
    cursor: pointer;
}

.mini-list {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.mini-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
}

.modal-actions,
.print-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.document {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
}

.doc-head,
.doc-meta,
.doc-total {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.doc-head {
    border-bottom: 2px solid var(--ink);
    padding-bottom: 18px;
}

.doc-head h1 {
    margin: 0 0 4px;
}

.doc-total {
    border-top: 2px solid var(--ink);
    padding-top: 16px;
    margin-top: 18px;
    font-size: 18px;
}

.receipt-challan {
    width: min(980px, 100%);
    margin: 0 auto;
    background: #fff7fb;
    border: 1px solid #c9b6c9;
    border-radius: 4px;
    padding: 28px 34px 34px;
    color: #383052;
    box-shadow: 0 10px 30px rgba(24, 32, 42, .08);
}

.challan-top,
.challan-party,
.challan-footer {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.challan-top {
    font-size: 15px;
    margin-bottom: 4px;
}

.challan-top strong,
.challan-top span {
    display: inline-block;
    min-width: 120px;
    border-bottom: 1px dotted #5f5674;
    margin-left: 8px;
    padding: 0 8px 2px;
    font-size: 20px;
}

.challan-title {
    border-bottom: 1px solid #5f5674;
    font-weight: 900;
    text-align: center;
}

.challan-company {
    text-align: center;
    margin-bottom: 14px;
}

.challan-company h1 {
    margin: 0;
    color: #3b4088;
    font-size: 25px;
    line-height: 1.15;
}

.challan-company p {
    margin: 2px 0;
    font-weight: 700;
}

.challan-party {
    border-bottom: 1px dotted #5f5674;
    margin-bottom: 3px;
    padding-bottom: 2px;
    font-size: 17px;
}

.challan-party div:first-child {
    flex: 1;
}

.challan-lines {
    border-collapse: collapse;
    margin-top: 0;
}

.challan-lines th,
.challan-lines td {
    border: 1px solid #5f5674;
    height: 32px;
    padding: 5px 8px;
    color: #383052;
}

.challan-lines th:first-child,
.challan-lines td:first-child {
    width: 17%;
}

.challan-lines th:nth-child(2),
.challan-lines td:nth-child(2) {
    width: 27%;
}

.challan-lines th {
    background: transparent;
    text-align: center;
    text-transform: none;
    font-size: 13px;
}

.challan-footer {
    align-items: end;
    margin-top: 16px;
    font-size: 15px;
    font-weight: 800;
}

.challan-footer div:last-child {
    min-width: 360px;
    display: grid;
    gap: 28px;
    text-align: center;
}

.out-bill {
    width: min(980px, 100%);
    margin: 0 auto;
    background: #fff;
    border: 1px solid #b8b0bd;
    border-radius: 4px;
    padding: 28px 34px 34px;
    color: #383052;
    box-shadow: 0 10px 30px rgba(24, 32, 42, .08);
}

.bill-top,
.bill-footer,
.bill-summary {
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.bill-top {
    align-items: flex-start;
    font-size: 15px;
}

.bill-top strong,
.bill-top span {
    display: inline-block;
    min-width: 120px;
    border-bottom: 1px dotted #5f5674;
    margin-left: 8px;
    padding: 0 8px 2px;
    font-size: 20px;
}

.bill-title {
    border-bottom: 1px solid #5f5674;
    font-weight: 950;
    text-align: center;
}

.bill-company {
    text-align: center;
    margin-bottom: 12px;
}

.bill-company h1 {
    margin: 0;
    color: #313876;
    font-size: 24px;
    line-height: 1.15;
}

.bill-company p {
    margin: 2px 0;
    font-weight: 700;
}

.bill-party {
    display: flex;
    gap: 10px;
    border-bottom: 1px dotted #5f5674;
    margin-bottom: 3px;
    font-size: 17px;
}

.bill-party span {
    flex: 1;
}

.bill-lines {
    border-collapse: collapse;
}

.bill-lines th,
.bill-lines td {
    border: 1px solid #5f5674;
    height: 32px;
    padding: 5px 8px;
    color: #383052;
}

.bill-lines th {
    background: transparent;
    text-align: center;
    text-transform: none;
    font-size: 13px;
}

.bill-lines th:first-child,
.bill-lines td:first-child {
    width: 8%;
    text-align: center;
}

.bill-lines th:nth-child(2),
.bill-lines td:nth-child(2) {
    width: 30%;
}

.bill-lines th:nth-child(4),
.bill-lines td:nth-child(4),
.bill-lines th:nth-child(5),
.bill-lines td:nth-child(5),
.bill-lines th:nth-child(6),
.bill-lines td:nth-child(6),
.bill-lines th:nth-child(7),
.bill-lines td:nth-child(7) {
    text-align: right;
}

.bill-summary {
    align-items: flex-start;
    margin-top: 14px;
}

.bill-words {
    flex: 1;
    font-weight: 900;
}

.bill-words span {
    display: block;
    min-height: 34px;
    border-bottom: 1px dotted #5f5674;
}

.bill-total {
    min-width: 280px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 14px;
    font-weight: 900;
}

.bill-total strong {
    text-align: right;
}

.bill-footer {
    align-items: end;
    margin-top: 16px;
    font-size: 15px;
    font-weight: 800;
}

.bill-footer div:last-child {
    min-width: 420px;
    display: grid;
    gap: 28px;
    text-align: center;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1080px) {
    .sidebar {
        position: static;
        width: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .app {
        margin-left: 0;
        padding: 18px;
    }

    .floor-grid,
    .two-col,
    .three-col,
    .chamber-tables,
    .report-grid,
    .statement-grid {
        grid-template-columns: 1fr;
    }

    .room-grid {
        grid-template-columns: repeat(4, minmax(80px, 1fr));
    }
}

@media (max-width: 640px) {
    .topbar,
    .doc-head,
    .doc-meta,
    .doc-total {
        display: grid;
    }

    .sidebar nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .floor-grid,
    .room-grid {
        grid-template-columns: 1fr;
    }

    .ledger-summary {
        grid-template-columns: 1fr;
    }

    .floor-button {
        min-height: 130px;
    }

    .chamber-table {
        overflow-x: auto;
    }

    .chamber-row {
        grid-template-columns: 48px repeat(10, 70px);
    }

    .form-head {
        align-items: stretch;
    }
}

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .topbar,
    .notice,
    .print-actions {
        display: none;
    }

    .app {
        margin: 0;
        padding: 0;
    }

    .document {
        border: 0;
        padding: 0;
    }

    .receipt-challan {
        width: 100%;
        box-shadow: none;
        border: 0;
        padding: 8mm;
        background: #fff;
    }

    .challan-lines th,
    .challan-lines td {
        border-color: #333;
    }

    .out-bill {
        width: 100%;
        box-shadow: none;
        border: 0;
        padding: 8mm;
    }

    .bill-lines th,
    .bill-lines td {
        border-color: #333;
    }
}
