/* ========================================
   珮慈的工作備忘錄 — 全域樣式
   ======================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* 主色調：藍 */
  --blue:         #2563EB;
  --blue-dark:    #1D4ED8;
  --blue-light:   #EFF6FF;
  --blue-border:  #BFDBFE;

  /* 背景 */
  --bg-page:      #F8FAFC;
  --bg-card:      #FFFFFF;

  /* 文字 */
  --text:         #1E293B;
  --text-secondary: #64748B;
  --text-muted:   #94A3B8;

  /* 邊框 */
  --border:       #E2E8F0;

  /* 狀態色 */
  --green:        #10B981;
  --green-light:  #ECFDF5;
  --amber:        #F59E0B;
  --amber-light:  #FFFBEB;
  --red:          #EF4444;
  --red-light:    #FEF2F2;

  /* 佈局 */
  --sidebar-w:    240px;
  --topbar-h:     56px;
  --radius:       8px;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.05);
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);

  /* 預設 light mode */
  color-scheme: light;
}

[data-theme="dark"] {
  --blue:         #60A5FA;
  --blue-dark:    #93BBFD;
  --blue-light:   #1E3A5F;
  --blue-border:  #2D4A6F;
  --bg-page:      #0F172A;
  --bg-card:      #1E293B;
  --text:         #E2E8F0;
  --text-secondary: #94A3B8;
  --text-muted:   #64748B;
  --border:       #334155;
  --green:        #34D399;
  --green-light:  #064E3B;
  --amber:        #FBBF24;
  --amber-light:  #451A03;
  --red:          #F87171;
  --red-light:    #450A0A;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.3);
  --shadow:       0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md:    0 4px 6px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
  color-scheme: dark;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Zen Kaku Gothic New", "PingFang TC", "Noto Sans TC",
               "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.6;
  min-height: 100vh;
  transition: background .3s, color .3s;
}

a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  color: var(--blue-dark);
}

/* --- Layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-container {
  flex: 1;
  padding: 20px 16px 40px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

/* --- Topbar (mobile) --- */
.topbar {
  display: flex;
  align-items: center;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.topbar-menu-btn:hover {
  background: var(--blue-light);
}

.menu-icon,
.menu-icon::before,
.menu-icon::after {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.menu-icon {
  position: relative;
}
.menu-icon::before,
.menu-icon::after {
  content: '';
  position: absolute;
  left: 0;
}
.menu-icon::before { top: -6px; }
.menu-icon::after  { top:  6px; }

.topbar-title {
  margin-left: 8px;
  font-weight: 600;
  font-size: 1rem;
  color: var(--blue-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-spacer {
  flex: 1;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform .25s ease;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 99;
  display: none;
}
.sidebar-overlay.show {
  display: block;
}

.sidebar-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--blue-dark);
  display: block;
}
.sidebar-brand:hover {
  color: var(--blue);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-link {
  display: block;
  padding: 10px 20px;
  font-size: .925rem;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar-link:hover {
  background: var(--blue-light);
  color: var(--text);
}
.sidebar-link.active {
  color: var(--blue);
  background: var(--blue-light);
  border-left-color: var(--blue);
  font-weight: 600;
}

.sidebar-section-title {
  padding: 20px 20px 6px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .85rem;
  color: var(--text-muted);
}

.sidebar-user {
  font-weight: 500;
  color: var(--text-secondary);
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logout {
  color: var(--text-muted);
  font-size: .85rem;
}
.sidebar-logout:hover {
  color: var(--red);
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.theme-toggle-btn:hover {
  background: var(--blue-light);
  color: var(--text-secondary);
}

/* light mode: 顯示月亮 icon（切到 dark），隱藏太陽 */
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark  { display: block; }
.theme-icon-light { display: block; }
.theme-icon-dark  { display: none; }

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  display: block;
  font-size: .875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: .925rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  line-height: 1.4;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--blue-light);
  border-color: var(--blue-border);
  color: var(--blue-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--blue-light);
  color: var(--blue-dark);
}

.btn-block {
  width: 100%;
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover {
  opacity: .9;
  color: #fff;
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: .8rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
  line-height: 1.4;
}
.btn-sm:hover {
  background: var(--blue-light);
  color: var(--blue-dark);
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

.card-link {
  font-size: .85rem;
  font-weight: 500;
}

.card-body {
  padding: 16px 20px;
}

/* --- Stats Row --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--border);
}

.stat-pending { border-left-color: var(--amber); }
.stat-done    { border-left-color: var(--green); }
.stat-plates  { border-left-color: var(--blue); }

.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Dashboard Grid --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* --- Dash List --- */
.dash-list {
  list-style: none;
}

.dash-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.dash-item:last-child {
  border-bottom: none;
}

.dash-category {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.dash-content {
  flex: 1;
  font-size: .925rem;
  min-width: 0;
  word-break: break-word;
}

.dash-date {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* --- Category Colors --- */
.cat-住戶事務   { background: #F0FDF4; color: #16A34A; }
.cat-車牌       { background: #FEF3C7; color: #B45309; }
.cat-租約       { background: #F3E8FF; color: #7C3AED; }
.cat-施工裝潢   { background: #FCE7F3; color: #BE185D; }
.cat-其他       { background: #F1F5F9; color: #475569; }
.cat-新增       { background: #ECFDF5; color: #059669; }
.cat-變更       { background: #EFF6FF; color: #2563EB; }
.cat-延期       { background: #FEF3C7; color: #B45309; }
.cat-刪除       { background: #FEF2F2; color: #DC2626; }

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.filter-input {
  flex: 1;
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text);
  background: var(--bg-card);
}
.filter-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}
.filter-input-sm {
  flex: 0 1 130px;
  min-width: 110px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text);
  background: var(--bg-card);
  cursor: pointer;
  min-width: 100px;
}
.filter-select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}

/* 篩選列：帶標籤的日期欄位 */
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 1 150px;
  min-width: 120px;
}
.filter-field .filter-input {
  flex: none;
  width: 100%;
  min-width: 0;
}
.filter-field-label {
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-muted);
  padding-left: 2px;
}

/* 匯出按鈕：與篩選欄位同高、有邊框 */
.btn-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.btn-export:hover {
  background: var(--blue-light);
  color: var(--blue-dark);
}

/* 桌面端：列包裝層透明，不影響 flex 佈局 */
.filter-select-row,
.filter-date-row,
.filter-action-row {
  display: contents;
}

/* --- Memo List --- */
.memo-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.memo-card {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
  transition: box-shadow .15s;
}
.memo-card:hover {
  box-shadow: var(--shadow-md);
}
.memo-done {
  opacity: .65;
}

.memo-status-bar {
  width: 4px;
  flex-shrink: 0;
}
.status-pending { background: var(--amber); }
.status-done    { background: var(--green); }
.type-新增     { background: var(--green); }
.type-變更     { background: var(--blue); }
.type-延期     { background: var(--amber); }
.type-刪除     { background: var(--red); }

.memo-body {
  flex: 1;
  padding: 14px 16px;
  min-width: 0;
}

.memo-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.memo-category {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
}

.memo-date {
  font-size: .8rem;
  color: var(--text-muted);
}

.memo-content {
  font-size: .95rem;
  margin-bottom: 6px;
  word-break: break-word;
}

.memo-note {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.memo-handler {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.memo-status-text {
  font-size: .8rem;
  color: var(--text-muted);
}

.memo-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* --- Comments --- */
.comment-list {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.comment-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: .85rem;
  flex-wrap: wrap;
}
.comment-author {
  font-weight: 600;
  color: var(--blue);
  white-space: nowrap;
  flex-shrink: 0;
}
.comment-text {
  flex: 1;
  color: var(--text-secondary);
  min-width: 0;
  word-break: break-word;
}
.comment-time {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.comment-form {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.comment-as {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.comment-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .8rem;
  color: var(--text);
  background: var(--bg-card);
  flex-shrink: 0;
}
.comment-input {
  flex: 1;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  color: var(--text);
  background: var(--bg-card);
  min-width: 0;
}
.comment-input:focus {
  outline: none;
  border-color: var(--blue);
}
.btn-sm-link {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: var(--blue);
  font-size: .75rem;
  cursor: pointer;
  text-decoration: underline;
  flex-shrink: 0;
}
.btn-sm-link:hover {
  color: var(--blue-dark);
}

.btn-delete-comment {
  color: var(--text-muted);
}
.btn-delete-comment:hover {
  color: var(--red);
}

/* --- Comment Dots Menu --- */
.comment-menu {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;
}

.btn-comment-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  letter-spacing: 1px;
}
.btn-comment-dots:hover {
  background: var(--blue-light);
  color: var(--text-secondary);
}

.comment-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 60;
  min-width: 90px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 4px 0;
  white-space: nowrap;
}
.comment-dropdown.open {
  display: block;
}

.comment-dropdown-item {
  display: block;
  width: 100%;
  padding: 6px 14px;
  font-size: .8rem;
  text-align: left;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
}
.comment-dropdown-item:hover {
  background: var(--blue-light);
  color: var(--text);
}
.comment-dropdown-item.item-delete:hover {
  background: var(--red-light);
  color: var(--red);
}
.comment-edit-form {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
  flex: 1 0 100%;
}

/* --- Comment Reply --- */
.comment-reply {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0 6px 28px;
  font-size: .85rem;
  flex-wrap: wrap;
  border-left: 2px solid var(--border);
  margin-left: 8px;
}

.comment-reply-deep {
  margin-left: 28px;
  font-size: .82rem;
}

.btn-reply-toggle {
  color: var(--text-muted);
}
.btn-reply-toggle:hover {
  color: var(--text-secondary);
}

.reply-form {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
  flex: 1 0 100%;
  flex-wrap: wrap;
}
.reply-form .comment-select {
  font-size: .78rem;
  padding: 3px 6px;
}
.reply-form .comment-input {
  font-size: .82rem;
  padding: 3px 8px;
}
.reply-form .btn-sm {
  font-size: .75rem;
  padding: 3px 10px;
}

/* 手機端回覆表單 */
@media (max-width: 767px) {
  .reply-form {
    flex-direction: column;
    align-items: stretch;
  }
  .reply-form .comment-select {
    width: 100%;
  }
}

/* --- Forms --- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

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

.form-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  color: var(--text);
  background: var(--bg-card);
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.form-error {
  background: var(--red-light);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 16px;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}

.empty-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* --- Login Page --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, var(--blue-light) 0%, var(--bg-page) 100%);
}

.login-card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--blue-dark);
  text-align: center;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: .875rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-label {
  font-size: .875rem;
  font-weight: 600;
}

.login-input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-page);
  transition: border-color .15s, box-shadow .15s;
}
.login-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}

.login-error {
  background: var(--red-light);
  color: var(--red);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: .875rem;
}

/* --- Responsive --- */

/* Tablet up: show sidebar */
@media (min-width: 768px) {
  .main-content {
    margin-left: var(--sidebar-w);
  }

  .sidebar {
    transform: translateX(0);
  }

  .topbar {
    display: none;
  }

  .page-container {
    padding: 28px 32px 40px;
    margin: 0 auto;
  }

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

  .stats-row {
    grid-template-columns: repeat(3, 1fr);
  }

  /* 篩選列桌面端：搜尋框限寬、按鈕高度對齊 */
  .filter-bar > .filter-input:not(.filter-input-sm) {
    flex: 0 1 280px;
  }
  .filter-bar .btn-secondary {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .filter-bar .btn-export {
    padding: 10px 10px;
  }
  .filter-bar .btn-export svg {
    width: 18px;
    height: 18px;
  }
}

/* Desktop: more breathing room */
@media (min-width: 1024px) {
  .page-container {
    padding: 32px 40px 48px;
  }
}

@media (max-width: 767px) {
  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .filter-input,
  .filter-input-sm,
  .filter-select {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
  }
  .filter-field {
    flex: 0 0 auto;
    width: 100%;
  }
  .filter-field .filter-input {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .filter-select-row,
  .filter-date-row,
  .filter-action-row {
    display: flex;
    gap: 8px;
    width: 100%;
  }
  .filter-select-row .filter-select {
    width: auto;
    flex: 1;
  }
  .filter-date-row .filter-field {
    width: auto;
    flex: 1;
  }
  .filter-action-row .btn-secondary,
  .filter-action-row .btn-export {
    flex: 1;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .filter-action-row .btn-export svg {
    width: 18px;
    height: 18px;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .form-input {
    width: 100%;
    min-width: 0;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .memo-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .memo-actions .btn-sm {
    flex: 1;
    text-align: center;
  }
  .comment-form {
    flex-direction: row;
    align-items: center;
  }
  .comment-select {
    width: auto;
    flex: 0 0 auto;
    min-width: 64px;
  }
}

/* --- Utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* --- Dark mode overrides --- */
[data-theme="dark"] .login-page {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
}
[data-theme="dark"] .filter-input,
[data-theme="dark"] .filter-select,
[data-theme="dark"] .form-input,
[data-theme="dark"] .comment-input,
[data-theme="dark"] .comment-select,
[data-theme="dark"] .login-input {
  background: #1E293B;
  color: var(--text);
}
[data-theme="dark"] .login-input {
  background: #0F172A;
}
[data-theme="dark"] .btn-sm {
  background: #334155;
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme="dark"] .btn-sm:hover {
  background: #475569;
  color: var(--text);
}
[data-theme="dark"] .btn-secondary {
  background: #334155;
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme="dark"] .btn-secondary:hover {
  background: #475569;
  color: var(--text);
}
[data-theme="dark"] .btn-export {
  background: #334155;
}
[data-theme="dark"] .btn-export:hover {
  background: #475569;
}

/* --- Focus visible --- */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}
