:root {
    --ink: #163c36;
    --ink-soft: #44645f;
    --primary: #167c6d;
    --primary-dark: #0d5f54;
    --primary-soft: #dff1eb;
    --mint: #eef8f4;
    --cream: #fbf8f1;
    --paper: #ffffff;
    --line: #dfe8e4;
    --accent: #f2a76f;
    --accent-soft: #fff1e5;
    --danger: #b94848;
    --danger-soft: #fae8e6;
    --warning: #a86b1d;
    --warning-soft: #fff3d8;
    --success: #197256;
    --shadow: 0 16px 44px rgba(22, 60, 54, .08);
    --shadow-soft: 0 6px 18px rgba(22, 60, 54, .06);
    --radius: 20px;
    --radius-sm: 12px;
    --sidebar-width: 248px;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--cream);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

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

img {
    display: block;
    max-width: 100%;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3,
strong {
    letter-spacing: -.015em;
}

.icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: currentColor;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    font-size: 20px;
    letter-spacing: -.04em;
}

.brand strong {
    font-weight: 800;
}

.brand-mark {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.brand-light {
    color: #fff;
}

.eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .15em;
    text-transform: uppercase;
}

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

.muted-small {
    color: #78908c;
    font-size: 12px;
}

.login-body {
    min-height: 100vh;
    background: #f5f0e8;
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(480px, 1.08fr) minmax(440px, .92fr);
    min-height: 100vh;
}

.login-visual {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 46px clamp(42px, 6vw, 90px) 38px;
    overflow: hidden;
    color: #fff;
    background: radial-gradient(circle at 78% 17%, rgba(111, 202, 178, .35), transparent 28%), linear-gradient(145deg, #17483f 0%, #0f6659 54%, #0b5148 100%);
}

.login-visual::before,
.login-visual::after {
    position: absolute;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 50%;
    content: "";
}

.login-visual::before {
    right: -180px;
    bottom: -200px;
    width: 560px;
    height: 560px;
}

.login-visual::after {
    top: 90px;
    left: -280px;
    width: 500px;
    height: 500px;
}

.login-copy {
    position: relative;
    z-index: 1;
    max-width: 650px;
    margin-top: clamp(55px, 8vh, 110px);
}

.login-copy .eyebrow {
    color: #a7dfd0;
}

.login-copy h1 {
    margin-bottom: 22px;
    font-size: clamp(38px, 4.4vw, 66px);
    line-height: 1.16;
}

.login-copy p {
    max-width: 560px;
    color: rgba(255, 255, 255, .76);
    font-size: 17px;
}

.login-illustration {
    position: absolute;
    z-index: 0;
    right: clamp(-35px, 2vw, 40px);
    bottom: 55px;
    width: min(52%, 520px);
    max-height: 46vh;
    object-fit: contain;
    filter: drop-shadow(0 24px 28px rgba(0, 0, 0, .18));
}

.login-flow {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    width: min(520px, 70%);
    margin-top: auto;
    color: rgba(255, 255, 255, .85);
    font-size: 13px;
    font-weight: 700;
}

.login-flow i {
    height: 1px;
    margin: 0 10px;
    background: rgba(255, 255, 255, .3);
    flex: 1;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 48px clamp(30px, 7vw, 104px) 28px;
    background: var(--paper);
    flex-direction: column;
}

.login-card {
    width: min(100%, 420px);
    margin: auto 0;
}

.login-card h2 {
    margin-bottom: 8px;
    font-size: 32px;
}

.login-card .muted {
    margin-bottom: 28px;
}

.mobile-brand {
    display: none;
    margin-bottom: 44px;
}

.login-panel footer {
    color: #91a09d;
    font-size: 12px;
}

.stack-form,
.compact-form {
    display: grid;
    gap: 18px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 750;
}

label small {
    color: #78908c;
    font-weight: 500;
}

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

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 124, 109, .12);
}

input:disabled {
    color: #71827f;
    background: #f3f6f5;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 11px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    transition: transform .16s, box-shadow .16s, background .16s;
}

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

.btn:focus-visible,
.icon-button:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(22, 124, 109, .22);
    outline-offset: 2px;
}

.btn-primary {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 7px 16px rgba(22, 124, 109, .18);
}

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

.btn-secondary {
    color: var(--ink);
    border-color: var(--line);
    background: #fff;
}

.btn-ghost {
    color: var(--ink-soft);
    background: transparent;
}

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

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

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

.btn-large {
    min-height: 50px;
    padding: 12px 20px;
}

.btn-small {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 12px;
}

.login-help {
    margin-top: 22px;
    color: #78908c;
    font-size: 12px;
    text-align: center;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 15px;
    border: 1px solid;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 650;
}

.alert-error {
    color: #8e3333;
    border-color: #efc5c1;
    background: var(--danger-soft);
}

.alert-success {
    color: #135c48;
    border-color: #b9dfd1;
    background: #e7f6ef;
}

.alert-warning {
    color: #835015;
    border-color: #ead39e;
    background: var(--warning-soft);
}

.alert-info {
    color: #245b71;
    border-color: #bfd9e4;
    background: #e9f5fa;
}

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

.sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    width: var(--sidebar-width);
    padding: 28px 18px 22px;
    overflow-y: auto;
    color: #eaf5f2;
    background: linear-gradient(180deg, #163f38 0%, #10352f 100%);
    flex-direction: column;
}

.sidebar-brand {
    margin: 0 10px 30px;
    color: #fff;
}

.sidebar-brand .brand-mark {
    width: 38px;
    height: 38px;
}

.main-nav {
    display: grid;
    gap: 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 10px 13px;
    color: rgba(234, 245, 242, .68);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    transition: color .18s, background .18s;
}

.nav-link:hover,
.nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

.nav-link.active {
    box-shadow: inset 3px 0 0 #72c6af;
}

.sidebar-tip {
    display: grid;
    margin-top: auto;
    padding: 15px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
    background: rgba(255, 255, 255, .06);
}

.sidebar-tip img {
    width: 80px;
    height: 72px;
    margin: -9px auto 4px;
    object-fit: contain;
}

.sidebar-tip strong {
    font-size: 13px;
}

.sidebar-tip span {
    color: rgba(255, 255, 255, .6);
    font-size: 11px;
    line-height: 1.5;
}

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    align-items: center;
    min-height: 72px;
    padding: 0 clamp(22px, 4vw, 54px);
    border-bottom: 1px solid rgba(223, 232, 228, .8);
    background: rgba(251, 248, 241, .91);
    backdrop-filter: blur(14px);
}

.topbar-spacer {
    flex: 1;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    display: inline-grid;
    width: 38px;
    height: 38px;
    color: #fff;
    border-radius: 12px;
    background: var(--primary);
    font-weight: 800;
    place-items: center;
}

.avatar-small {
    width: 34px;
    height: 34px;
    border-radius: 10px;
}

.user-meta {
    display: grid;
    margin-right: 8px;
    line-height: 1.2;
}

.user-meta strong {
    font-size: 13px;
}

.user-meta small {
    margin-top: 4px;
    color: #80928e;
    font-size: 10px;
}

.icon-button {
    display: inline-grid;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--ink-soft);
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    background: transparent;
    place-items: center;
}

.icon-button:hover {
    color: var(--ink);
    background: #e9f0ed;
}

.mobile-menu-button {
    display: none;
}

.content {
    width: min(100%, 1540px);
    margin: 0 auto;
    padding: 34px clamp(22px, 4vw, 54px) 72px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.page-header h1 {
    margin-bottom: 7px;
    font-size: clamp(28px, 3vw, 40px);
    line-height: 1.2;
}

.page-header p {
    max-width: 690px;
    margin-bottom: 0;
    color: var(--ink-soft);
}

.page-actions {
    display: flex;
    gap: 10px;
}

.panel {
    margin-bottom: 22px;
    padding: 24px;
    border: 1px solid rgba(216, 228, 223, .9);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-soft);
}

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

.panel-header h2,
.panel-header h3 {
    margin-bottom: 2px;
    font-size: 20px;
}

.panel-header p {
    margin: 0;
    color: #7c918d;
    font-size: 12px;
}

.text-link {
    display: inline-flex;
    align-items: center;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
}

.text-link .icon {
    width: 17px;
}

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

.stat-card {
    position: relative;
    display: grid;
    min-height: 146px;
    padding: 21px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.stat-card::after {
    position: absolute;
    top: -34px;
    right: -30px;
    width: 105px;
    height: 105px;
    border-radius: 50%;
    content: "";
    background: var(--primary-soft);
}

.stat-card > span {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 750;
}

.stat-card strong {
    align-self: center;
    font-size: clamp(27px, 2.5vw, 38px);
    line-height: 1;
}

.stat-card small {
    align-self: end;
    color: #81938f;
}

.stat-pending::after {
    background: var(--warning-soft);
}

.stat-payment::after {
    background: #e7edf9;
}

.stat-month::after {
    background: var(--accent-soft);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(270px, .65fr);
    gap: 22px;
}

.recent-panel,
.process-panel {
    margin-bottom: 0;
}

.process-panel h2 {
    font-size: 20px;
}

.process-list {
    display: grid;
    gap: 0;
    margin: 22px 0 0;
    padding: 0;
    list-style: none;
}

.process-list li {
    position: relative;
    display: flex;
    gap: 13px;
    min-height: 66px;
}

.process-list li:not(:last-child)::before {
    position: absolute;
    top: 32px;
    bottom: -2px;
    left: 15px;
    width: 1px;
    content: "";
    background: var(--line);
}

.process-list b {
    position: relative;
    z-index: 1;
    display: grid;
    width: 31px;
    height: 31px;
    color: var(--primary);
    border: 1px solid #b9d9d0;
    border-radius: 50%;
    background: #fff;
    font-size: 12px;
    place-items: center;
}

.process-list .done b {
    color: #fff;
    background: var(--primary);
}

.process-list div {
    display: grid;
    padding-top: 2px;
}

.process-list strong {
    font-size: 13px;
}

.process-list span {
    color: #81938f;
    font-size: 11px;
}

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

table {
    width: 100%;
    border-spacing: 0;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 9px 12px;
    color: #728682;
    border-bottom: 1px solid var(--line);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    white-space: nowrap;
}

td {
    padding: 14px 12px;
    border-bottom: 1px solid #edf2f0;
    font-size: 13px;
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: 0;
}

td strong,
td small {
    display: block;
}

td small {
    margin-top: 2px;
    color: #849692;
    font-size: 10px;
}

.purpose-cell {
    min-width: 190px;
    max-width: 340px;
}

.amount-cell {
    font-weight: 800;
    white-space: nowrap;
}

.amount-cell.positive {
    color: var(--success);
}

.amount-cell.negative {
    color: var(--danger);
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.status-waiting {
    color: #8a5a16;
    background: var(--warning-soft);
}

.status-approved {
    color: #315d97;
    background: #e7eefb;
}

.status-paid {
    color: #7152a0;
    background: #f0e9fa;
}

.status-completed {
    color: #176149;
    background: #e3f4ed;
}

.status-returned,
.status-voided {
    color: #963d3d;
    background: var(--danger-soft);
}

.reason-text {
    display: block;
    max-width: 170px;
    margin-top: 5px;
    color: var(--danger);
    font-size: 10px;
}

.row-actions {
    display: flex;
    align-items: flex-start;
    min-width: 155px;
    flex-wrap: wrap;
    gap: 7px;
}

.inline-form {
    display: inline-flex;
}

.action-details {
    position: relative;
    display: inline-block;
}

.action-details[open] {
    width: 280px;
}

.action-details > summary {
    list-style: none;
}

.action-details > summary::-webkit-details-marker {
    display: none;
}

.popover-form {
    position: static;
    display: grid;
    width: 280px;
    margin-top: 8px;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow);
}

.chip-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.chip-link .icon {
    width: 15px;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 30px;
    text-align: left;
}

.empty-state img {
    width: min(44%, 270px);
    max-height: 240px;
    object-fit: contain;
}

.empty-state h3 {
    margin-bottom: 5px;
}

.empty-state p {
    max-width: 300px;
    color: var(--ink-soft);
}

.empty-compact {
    display: grid;
    min-height: 160px;
    color: var(--ink-soft);
    text-align: center;
    place-content: center;
}

.empty-compact strong {
    color: var(--ink);
}

.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    align-items: start;
    gap: 22px;
}

.form-panel {
    padding: clamp(24px, 4vw, 40px);
}

.form-section-heading {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 20px;
}

.form-section-heading.spaced {
    margin-top: 34px;
}

.form-section-heading > span {
    display: grid;
    width: 36px;
    height: 36px;
    color: var(--primary);
    border-radius: 11px;
    background: var(--primary-soft);
    font-size: 11px;
    font-weight: 900;
    place-items: center;
}

.form-section-heading h2 {
    margin: 0;
    font-size: 18px;
}

.form-section-heading p {
    margin: 0;
    color: #80928e;
    font-size: 11px;
}

.form-grid {
    display: grid;
    gap: 17px;
}

.form-grid.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full {
    grid-column: 1 / -1;
}

.upload-zone {
    display: flex;
    align-items: center;
    min-height: 120px;
    margin-bottom: 18px;
    padding: 16px;
    color: var(--ink);
    border: 1.5px dashed #a9c7bf;
    border-radius: 15px;
    cursor: pointer;
    background: var(--mint);
    gap: 17px;
}

.upload-zone:hover,
.upload-zone.has-file {
    border-color: var(--primary);
    background: #e5f5ef;
}

.upload-zone input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.upload-zone img {
    width: 86px;
    height: 78px;
    object-fit: contain;
}

.upload-zone span {
    display: grid;
}

.upload-zone strong {
    font-size: 14px;
}

.upload-zone small {
    color: #738b86;
    font-size: 11px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 26px;
    gap: 10px;
}

.form-help {
    position: sticky;
    top: 94px;
    padding: 24px;
    background: #f2f8f5;
}

.form-help img {
    width: 170px;
    height: 130px;
    margin: -8px auto 10px;
    object-fit: contain;
}

.form-help h3 {
    margin-bottom: 8px;
}

.form-help ul {
    display: grid;
    margin: 0 0 15px;
    padding-left: 20px;
    color: var(--ink-soft);
    gap: 5px;
}

.form-help p {
    margin: 0;
    color: #78908c;
    font-size: 12px;
}

.balance-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    padding: 22px 26px;
    color: #fff;
    border-radius: var(--radius);
    background: linear-gradient(115deg, #14695d, #1a8977);
    box-shadow: 0 14px 32px rgba(22, 124, 109, .2);
}

.balance-banner div {
    display: grid;
}

.balance-banner span {
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
}

.balance-banner strong {
    font-size: 28px;
}

.balance-banner p {
    margin: 0;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
}

.count-pill {
    display: grid;
    min-width: 34px;
    height: 28px;
    color: var(--primary);
    border-radius: 999px;
    background: var(--primary-soft);
    font-size: 12px;
    font-weight: 900;
    place-items: center;
}

.filter-panel {
    padding: 18px 20px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
    align-items: end;
    gap: 12px;
}

.filter-grid label {
    font-size: 11px;
}

.filter-grid input,
.filter-grid select {
    min-height: 41px;
    padding: 8px 10px;
    font-size: 12px;
}

.filter-actions {
    display: flex;
    gap: 5px;
}

.settings-tabs {
    position: sticky;
    z-index: 10;
    top: 80px;
    display: flex;
    width: fit-content;
    margin-bottom: 28px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .92);
    box-shadow: var(--shadow-soft);
    gap: 4px;
}

.settings-tabs a {
    padding: 7px 13px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
}

.settings-tabs a:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.settings-section {
    margin-bottom: 52px;
    scroll-margin-top: 145px;
}

.section-title {
    margin-bottom: 18px;
}

.section-title h2 {
    margin-bottom: 5px;
    font-size: 25px;
}

.section-title p {
    color: var(--ink-soft);
}

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

.compact-form h3 {
    margin-bottom: -8px;
}

.compact-form > p {
    margin-bottom: 0;
    color: var(--ink-soft);
    font-size: 12px;
}

.list-stack {
    display: grid;
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 8px 0;
    border-bottom: 1px solid #edf2f0;
    gap: 15px;
}

.list-row:last-child {
    border-bottom: 0;
}

.list-row div {
    display: grid;
}

.list-row small {
    color: #81938f;
    font-size: 11px;
}

.user-settings-grid {
    grid-template-columns: minmax(280px, .72fr) minmax(420px, 1.28fr);
    align-items: start;
}

.user-list {
    display: grid;
    gap: 0;
}

.user-row {
    border-bottom: 1px solid #edf2f0;
}

.user-row:last-child {
    border-bottom: 0;
}

.user-row summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    min-height: 64px;
    padding: 8px 2px;
    cursor: pointer;
    list-style: none;
    gap: 11px;
}

.user-row summary::-webkit-details-marker {
    display: none;
}

.user-row summary > span:nth-child(2) {
    display: grid;
}

.user-row summary small {
    color: #81938f;
    font-size: 10px;
}

.account-state {
    color: #963d3d;
    font-size: 11px;
    font-weight: 800;
}

.account-state.active {
    color: var(--success);
}

.user-actions {
    display: flex;
    align-items: end;
    padding: 6px 0 16px 47px;
    gap: 10px;
}

.password-reset-form {
    display: flex;
    align-items: end;
    gap: 7px;
}

.password-reset-form input {
    min-height: 34px;
    max-width: 190px;
    padding: 6px 9px;
}

@media (max-width: 1180px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-grid {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }

    .filter-actions {
        grid-column: span 3;
        justify-content: flex-end;
    }
}

@media (max-width: 960px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-visual {
        display: none;
    }

    .mobile-brand {
        display: inline-flex;
    }

    .login-panel {
        padding: 36px 24px 24px;
    }

    .sidebar {
        transform: translateX(-102%);
        transition: transform .22s ease;
    }

    body.nav-open .sidebar {
        transform: translateX(0);
        box-shadow: 16px 0 40px rgba(8, 36, 31, .25);
    }

    body.nav-open::after {
        position: fixed;
        z-index: 40;
        inset: 0;
        content: "";
        background: rgba(8, 34, 30, .35);
    }

    .app-main {
        margin-left: 0;
    }

    .mobile-menu-button {
        display: inline-grid;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .form-layout {
        grid-template-columns: 1fr;
    }

    .form-help {
        position: static;
    }
}

@media (max-width: 720px) {
    .topbar {
        min-height: 64px;
        padding: 0 16px;
    }

    .user-meta {
        display: none;
    }

    .content {
        padding: 24px 14px 54px;
    }

    .page-header {
        align-items: flex-start;
        margin-bottom: 22px;
        flex-direction: column;
    }

    .page-header h1 {
        font-size: 29px;
    }

    .page-actions,
    .page-actions .btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        min-height: 126px;
        padding: 16px;
    }

    .stat-card strong {
        font-size: 24px;
    }

    .panel {
        padding: 17px;
        border-radius: 15px;
    }

    .form-grid.two-col,
    .settings-grid,
    .user-settings-grid {
        grid-template-columns: 1fr;
    }

    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filter-actions {
        grid-column: span 2;
    }

    .balance-banner {
        align-items: flex-start;
        padding: 19px;
        flex-direction: column;
        gap: 8px;
    }

    .empty-state {
        text-align: center;
        flex-direction: column;
    }

    .empty-state img {
        width: 190px;
    }

    .row-actions {
        min-width: 140px;
    }

    .action-details[open],
    .popover-form {
        width: 260px;
    }

    .settings-tabs {
        top: 70px;
        width: 100%;
        justify-content: center;
    }

    .user-actions,
    .password-reset-form {
        align-items: stretch;
        padding-left: 0;
        flex-direction: column;
    }

    .password-reset-form input {
        max-width: none;
    }
}

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

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        grid-column: auto;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
