:root {
  --navy: #1F3864;
  --navy-light: #2E4E8C;
  --bg: #F4F6F9;
  --card: #FFFFFF;
  --border: #E1E5EB;
  --text: #1C2530;
  --muted: #6B7684;
  --green: #1E8E5A;
  --green-bg: #E6F4EC;
  --red: #C0392B;
  --red-bg: #FBEAE8;
  --yellow-bg: #FFF6D9;
  --yellow-border: #E9C64B;
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 14px;
}
a { color: var(--navy-light); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 54px;
}
.topbar .brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.topbar .brand a { color: white; }
.topbar .user-info { font-size: 12.5px; opacity: .9; }
.topbar .user-info a { color: #CFE0FF; margin-left: 10px; }

.navrow {
  background: #16294D;
  padding: 0 20px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
}
.navrow a {
  color: #D7E2F5;
  padding: 9px 12px;
  font-size: 13px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.navrow a:hover, .navrow a.active { color: white; border-bottom-color: #6FA8FF; text-decoration: none; }

.container { max-width: 1180px; margin: 0 auto; padding: 20px; }
.container.narrow { max-width: 640px; }

h1 { font-size: 21px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
.page-sub { color: var(--muted); margin-bottom: 18px; font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 18px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13.5px; }
.flash.success { background: var(--green-bg); color: var(--green); border: 1px solid #BFE6CE; }
.flash.error { background: var(--red-bg); color: var(--red); border: 1px solid #F0C4BE; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: #F0F2F6; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .3px; }
tr:hover td { background: #FAFBFD; }

.btn {
  display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--navy);
  background: var(--navy); color: white; font-size: 13px; cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--navy-light); text-decoration: none; }
.btn.secondary { background: white; color: var(--navy); border-color: var(--border); }
.btn.secondary:hover { background: #F0F2F6; }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.green { background: var(--green); border-color: var(--green); }

label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 5px;
  font-size: 13.5px; font-family: inherit; margin-bottom: 12px; background: white;
}
textarea { resize: vertical; min-height: 60px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > div { flex: 1; min-width: 160px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .2px; }
.badge.reorder { background: var(--red-bg); color: var(--red); }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.draft { background: #ECECEC; color: #555; }
.badge.pending_approval { background: var(--yellow-bg); color: #8A6D1D; border: 1px solid var(--yellow-border);}
.badge.needs_revision { background: var(--red-bg); color: var(--red); }
.badge.approved { background: var(--green-bg); color: var(--green); }
.badge.sent_to_supplier { background: #E4EEFB; color: #205297; }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; min-width: 150px; flex: 1; }
.stat-tile .num { font-size: 26px; font-weight: 700; color: var(--navy); }
.stat-tile .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

.filters { display: flex; gap: 10px; align-items: end; margin-bottom: 14px; flex-wrap: wrap; }
.filters > div { min-width: 160px; }
.filters label { margin-bottom: 3px; }
.filters input, .filters select { margin-bottom: 0; }

.approval-box { border: 1px solid var(--border); border-radius: 7px; padding: 12px; margin-bottom: 10px; }
.approval-box .role { font-weight: 700; font-size: 13px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--navy); }
.login-card { background: white; border-radius: 10px; padding: 32px; width: 340px; }
.login-card h1 { text-align: center; margin-bottom: 20px; color: var(--navy); }

.help-box { background: #EEF3FC; border: 1px solid #CBDCF5; border-radius: 7px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px; }

.item-rows-table input, .item-rows-table select { margin-bottom: 0; }
