/* Shell and login styles, added on top of styles.css (which is used unchanged). */

a { color: var(--accent); }
input.input { width: 100%; font: inherit; font-size: 15px; color: var(--fg); outline: none; }
input.input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.2); }
input.input::placeholder { color: #94A3B8; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.block { width: 100%; }
.hidden, [hidden] { display: none !important; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-tight { display: flex; flex-direction: column; gap: 8px; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted-fg); font-size: 13px; }
.divider span.line { flex: 1; height: 1px; background: var(--border); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted-fg); }
.empty .dot { margin: 0 auto 10px; width: 44px; height: 44px; }

/* Login page */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: linear-gradient(160deg, #E6F4F2 0%, #F4F8F8 60%); }
.login-card { width: 420px; max-width: 100%; padding: 36px 36px 28px; }
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.brand-row .dot { width: 40px; height: 40px; }
.brand-name { font-size: 20px; font-weight: 700; }

/* App shell: sidebar on desktop, bottom tab bar on phones */
.tabbar { display: none; }
.sidebar .foot { overflow-wrap: anywhere; }
.sidebar .nav a { cursor: pointer; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: var(--space-4) var(--space-4) 104px; }
  .topbar { flex-wrap: wrap; gap: var(--space-3); }
  .topbar h1 { font-size: 20px; }
  .grid.g2, .grid.g3, .grid.g4 { grid-template-columns: 1fr; }
  .tabbar { display: grid; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: 72px;
    grid-template-columns: repeat(5, 1fr); padding-bottom: 12px; }
  .login-card { padding: 28px 22px 22px; }
}

/* Notices on settings sit above the grid */
#notice-area:not(:empty) { margin-bottom: var(--space-4); }
#notice-area .alert { align-items: center; }

/* Phase 2 screens: lists, filters, dialogs and attachments (design/screens/04, 05, 13) */
.grow { flex: 1; min-width: 0; }
.min { min-width: 0; }
.break { overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table.wide { min-width: 760px; }
.grid > * { min-width: 0; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.pdc-filters { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.pdc-filters .field { flex: 1 1 200px; min-width: 0; }
/* 待入帳: under 760px the table becomes one card a cheque (clearing.js cardHtml); the desktop table stays. */
.clear-cards { display: none; }
.clear-card { border-top: 1px solid var(--border); padding: 12px 16px; }
.clear-card.selected { background: #F0FDFA; }
.clear-card-top { display: flex; align-items: center; gap: 12px; }
.clear-card-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0; font-size: 14px; }
.clear-card-facts dt { color: var(--muted-fg); }
.clear-card-facts dd { margin: 0; }
.clear-card-actions { display: flex; justify-content: flex-end; }
@media (max-width: 760px) {
  .clear-table-wrap { display: none; }
  .clear-cards { display: block; }
}
.pdc-filters select { height: 42px; border: 1px solid #CBD5E1; border-radius: 8px; padding: 0 10px; font: inherit; font-size: 15px; background: #fff; color: var(--fg); width: 100%; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; width: 320px; max-width: 100%;
  border: 1px solid #CBD5E1; border-radius: 8px; padding: 0 12px; background: #fff; color: var(--muted-fg); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 15px; color: var(--fg); }
.seg span { cursor: pointer; user-select: none; }
.seg span:focus-visible, .link-button:focus-visible, .btn:focus-visible { outline: 3px solid rgba(15, 118, 110, 0.35); outline-offset: 2px; }
.seg span:not(.on):hover { background: #F1F5F9; }
.archived-note, .link-button { display: inline-flex; align-items: center; gap: 6px; }
.archived-note[hidden] { display: none; }
.empty-cell { text-align: center; color: var(--muted-fg); padding: 28px 12px; }
.empty-note { color: var(--muted-fg); font-size: 14px; padding: 16px 0; }
.group-row td { background: #FAFCFC; color: var(--muted-fg); font-size: 13px; font-weight: 600; }
tr.archived td { color: var(--muted-fg); }
td.actions { width: 1%; text-align: right; }
td.actions a { display: inline-flex; }
td .row-actions { justify-content: flex-end; }
.card .hd .spacer, .card .hd > span[style] { margin-left: auto; }
.crumbs a { color: var(--muted-fg); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.path-line { font-family: Consolas, "Noto Sans TC", monospace; font-size: 12px; overflow-wrap: anywhere; }
.attachment-list .attachment-row:first-child { padding-top: 4px; }
.attachment-row { align-items: flex-start; }
.attachment-row .row-actions { flex-wrap: nowrap; }
.attachment-upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.attachment-upload select { height: 40px; border: 1px solid #CBD5E1; border-radius: 8px; padding: 0 10px; font: inherit; background: #fff; }
.attachment-upload .btn:disabled { opacity: .6; cursor: progress; }
.attachment-upload [data-local-notice] .alert { margin: 0; width: 100%; }
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted-fg); font-size: 24px; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--muted); }
.tag { white-space: nowrap; }
.btn { text-decoration: none; }
td a.strong { text-decoration: none; }
td a.strong:hover { text-decoration: underline; }
td a.muted { text-decoration: none; }

/* Dialog forms (form.js) */
dialog.form-dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  color: var(--fg); box-shadow: 0 20px 50px rgba(15, 42, 42, 0.25); }
dialog.form-dialog::backdrop { background: rgba(15, 42, 42, 0.42); }
.fd-form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.fd-hd { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.fd-hd h2 { margin: 0; font-size: 17px; flex: 1; }
.fd-bd { padding: 18px 20px; display: grid; gap: 14px; overflow-y: auto; }
.fd-ft { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.fd-error { margin: 0; }
.fd-error[hidden] { display: none; }
.field { gap: 6px; }
.field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%; min-height: 42px; border: 1px solid #CBD5E1; border-radius: 8px; padding: 8px 12px;
  font: inherit; font-size: 15px; color: var(--fg); background: #fff; }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.2); }
.field .help { font-size: 13px; color: var(--muted-fg); }
.field .req { color: var(--destructive); }

@media (max-width: 760px) {
  .search { width: 100%; }
  .toolbar > .spacer { display: none; }
  .table-scroll table.wide { min-width: 680px; }
  .fd-bd { padding: 14px 16px; }
  .fd-ft .btn { flex: 1; justify-content: center; }
}

/* Phase 4a: the home page (SPEC §十二) and 待入帳 (SPEC §八) */
.home-stack { display: grid; gap: var(--space-4); }
.home-two { display: grid; grid-template-columns: 1.25fr 1fr; gap: var(--space-4); align-items: start; }
.home-two > * { min-width: 0; }
.home-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.home-kpis .kpi { padding: var(--space-4) var(--space-5); }
.home-kpis .kpi .value { font-size: 24px; }
a.list-row { color: inherit; text-decoration: none; border-radius: 8px; }
a.list-row:hover { background: #FAFCFC; }
a.list-row .strong { overflow-wrap: anywhere; }
button.cb { padding: 0; cursor: pointer; font: inherit; }
/* 待入帳 rows are dense: eight columns must fit a laptop beside the sidebar, with 退票 always visible. */
.clear-table th, .clear-table td { padding: 9px 8px; }
.clear-table th:first-child, .clear-table td:first-child { width: 40px; padding-left: 14px; }
.clear-table td:last-child, .clear-table th:last-child { padding-right: 14px; }
.clear-table td:last-child .btn { height: 34px; padding: 0 12px; white-space: nowrap; }
button.cb:focus-visible { outline: 3px solid rgba(15, 118, 110, 0.35); outline-offset: 2px; }

@media (max-width: 760px) {
  .home-two { grid-template-columns: 1fr; }
  .home-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .home-kpis .kpi { padding: var(--space-3) var(--space-4); }
  .home-kpis .kpi .value { font-size: 19px; }
  .home-kpis .kpi .note { font-size: 12px; }
  .selbar { flex-wrap: wrap; }
  .group-hd { flex-wrap: wrap; gap: 6px 10px; padding: 12px 14px; }
  .group-hd > span[style*="flex:1"] { display: none; }
}
