:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #dcdfe4;
  --text: #24292f;
  --muted: #6a737d;
  --brand: #1b4d6b;
  --brand-dark: #123549;
  --accent: #2b7a4b;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--brand); }

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--brand-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.sidebar-brand {
  padding: 0 20px 20px;
  font-weight: bold;
  font-size: 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar-brand span { font-weight: normal; font-size: 0.8rem; opacity: 0.8; }

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}
.sidebar li { margin: 0; }
.sidebar .nav-group {
  padding: 14px 20px 4px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
}
.sidebar a {
  display: block;
  padding: 8px 20px;
  color: #eef2f5;
  text-decoration: none;
}
.sidebar a:hover { background: rgba(255,255,255,0.1); }

.logout-form {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
}
.sidebar-user { font-size: 0.8rem; opacity: 0.7; margin-bottom: 6px; }

.link-button {
  background: none;
  border: none;
  color: #eef2f5;
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  text-decoration: underline;
}

.content {
  flex: 1;
  padding: 24px 32px;
  max-width: 1200px;
}

h1 { font-size: 1.4rem; margin-top: 0; }
h2 { font-size: 1.15rem; }

.flash {
  background: #eaf6ec;
  border: 1px solid #b7dfc0;
  color: #1e5c2f;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}
.form-error {
  background: #fbeaea;
  border: 1px solid #eabcbc;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
}
.card-muted { opacity: 0.8; }
.card-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.card-value { font-size: 1.5rem; font-weight: 600; }

.page-actions { margin: 16px 0; }
.button, button, input[type="submit"] {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
}
.button:hover, button:hover { background: var(--brand-dark); }
.button.secondary, button.secondary { background: var(--muted); }
.button.danger, button.danger { background: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
th, td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  text-align: left;
}
th { background: #eef1f4; font-weight: 600; }
td.num, th.num { text-align: right; }
tr:hover td { background: #fafbfc; }

form.filter-form {
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  max-width: 900px;
}
.form-grid.full { grid-template-columns: 1fr; }
.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
  gap: 4px;
}
.form-grid label.span-2 { grid-column: span 2; }
input[type="text"], input[type="date"], input[type="number"], input[type="password"], select, textarea {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
}

.pagination { display: flex; gap: 6px; margin-bottom: 20px; }
.pagination a, .pagination span {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
}
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--brand-dark);
}
.login-box {
  background: #fff;
  padding: 36px 40px;
  border-radius: 10px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-box h1 {
  text-align: center;
  font-size: 1.1rem;
  color: var(--brand-dark);
  line-height: 1.5;
}
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }

.slip-items-table input { width: 100%; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  background: #eef1f4;
}
.badge.done { background: #eaf6ec; color: #1e5c2f; }
.badge.pending { background: #fdf3e3; color: #8a5b00; }

.invoice-doc {
  background: #fff;
  border: 1px solid var(--border);
  padding: 24px;
  max-width: 900px;
  font-size: 0.85rem;
}
.invoice-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.invoice-to-box { border: 1px solid #999; padding: 10px 14px; width: 320px; }
.invoice-to-code { color: var(--muted); font-size: 0.75rem; }
.invoice-to-name { font-weight: bold; margin: 6px 0; }
.invoice-from-box { text-align: right; }
.invoice-title { font-size: 1.6rem; font-weight: bold; letter-spacing: 0.2em; }
.invoice-from-address, .invoice-bank { margin-top: 8px; font-size: 0.8rem; }
.invoice-summary { width: 100%; margin: 14px 0; text-align: center; }
.invoice-summary th { background: #eef1f4; font-size: 0.75rem; }
.invoice-summary td { font-weight: 600; }
.invoice-summary-final { background: #fdf3d0 !important; }
.invoice-detail th { background: #eef1f4; }
.invoice-remarks { background: #f6f7f9; font-size: 0.8rem; color: var(--muted); }
.invoice-subtotal td { font-weight: 600; background: #f6f7f9; }
.invoice-receipt-row td { font-style: italic; }
.invoice-tax-summary { width: 420px; margin-top: 16px; }
