:root {
  --bg: #f7f0e3;
  --paper: #fffdf7;
  --ink: #5b4636;
  --ink-soft: #8a7561;
  --line: #e6dcc8;
  --accent: #c98a5e;      /* 暖橘棕 */
  --accent-soft: #e8c9a8;
  --green: #7a9d6b;
  --red: #c97b6e;
  --shadow: 0 4px 16px rgba(120, 90, 50, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans TC", system-ui, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.5) 0, transparent 40%),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(201,138,94,.06) 32px);
  color: var(--ink);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ===== 登入 ===== */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 38px 34px;
  width: 100%; max-width: 360px;
  text-align: center;
}
.login-emoji { font-size: 48px; }
.login-card h1 { font-size: 22px; margin: 8px 0 4px; }
.login-sub { color: var(--ink-soft); margin: 0 0 22px; font-size: 14px; }
.login-card input {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); margin-bottom: 14px;
}
.login-card button {
  width: 100%; padding: 12px; font-size: 16px; font-weight: 700;
  background: var(--accent); color: #fff; border: none;
  border-radius: 12px; cursor: pointer; transition: .15s;
}
.login-card button:hover { background: #b3744a; }
.login-error { color: var(--red); font-size: 14px; min-height: 18px; margin: 10px 0 0; }

/* ===== 頂列 ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; background: var(--paper);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap; gap: 10px;
}
.brand { font-size: 20px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.month-select {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font-size: 15px; font-family: inherit;
}

.container { max-width: 1080px; margin: 0 auto; padding: 22px 18px 40px; }

/* ===== 摘要卡片 ===== */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 18px; padding: 18px; box-shadow: var(--shadow);
  text-align: center;
}
.card-label { color: var(--ink-soft); font-size: 14px; margin-bottom: 6px; }
.card-value { font-size: 26px; font-weight: 700; }
.card-expense .card-value { color: var(--red); }
.card-income .card-value { color: var(--green); }
.card-balance .card-value { color: var(--accent); }

/* ===== 版面 ===== */
.grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 18px; margin-bottom: 20px; }
.panel {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 17px; margin: 0 0 14px; }

/* ===== 表單 ===== */
.type-toggle { display: flex; gap: 16px; margin-bottom: 14px; }
.type-toggle label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 10px 12px; font-size: 16px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--accent); }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.primary-btn {
  flex: 1; padding: 12px; font-size: 15px; font-weight: 700; font-family: inherit;
  background: var(--accent); color: #fff; border: none; border-radius: 12px; cursor: pointer; transition: .15s;
}
.primary-btn:hover { background: #b3744a; }
.ghost-btn {
  padding: 9px 14px; font-size: 14px; font-family: inherit;
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: .15s;
}
.ghost-btn:hover { background: #f1e8d8; color: var(--ink); }

/* ===== 圖表 ===== */
.chart-wrap { position: relative; height: 230px; }

/* ===== 明細 ===== */
.list-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.list-tools { display: flex; gap: 8px; }
.list-tools input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font-family: inherit; font-size: 16px;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px dashed var(--line); font-size: 15px; }
th { color: var(--ink-soft); font-weight: 500; font-size: 13px; }
.right { text-align: right; }
.amount-expense { color: var(--red); font-weight: 700; }
.amount-income { color: var(--green); font-weight: 700; }
.cat-tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: #7a5230; font-size: 13px;
}
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; font-size: 15px;
  padding: 4px 6px; border-radius: 8px;
}
.icon-btn:hover { background: #f1e8d8; }
.empty-hint { text-align: center; color: var(--ink-soft); padding: 30px 10px; }

.footer { text-align: center; color: var(--ink-soft); font-size: 13px; padding: 20px; }

/* ===== 手機 ===== */
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .card { display: flex; align-items: center; justify-content: space-between; text-align: left; }
  .card-value { font-size: 22px; }
}
