:root {
  --brand: #511E84;
  --brand-dark: #3c1663;
  --bg: #f5f4f7;
  --text: #1f1a26;
  --border: #e0dce6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

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

.brand {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 2rem;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.sidebar nav a {
  color: #fff;
  text-decoration: none;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  opacity: 0.9;
}

.sidebar nav a:hover {
  background: var(--brand-dark);
  opacity: 1;
}

.nav-divider {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.2);
  padding-top: 1rem;
  font-size: 0.85rem;
}

.sidebar-user {
  opacity: 0.85;
  word-break: break-all;
  margin-bottom: 0.5rem;
}

.logout-link {
  color: #fff;
}

.content {
  flex-grow: 1;
  padding: 2rem;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  font-size: 1.1rem;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  text-align: center;
  width: 90%;
  max-width: 360px;
}

.login-logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 0.25rem;
}

.login-sub {
  color: #666;
  margin-bottom: 1.5rem;
}

.btn-google {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  padding: 0.7rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
}

.btn-google:hover {
  background: var(--brand-dark);
}

.page-sub {
  color: #666;
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
}

.flash-ok {
  background: #e6f6ec;
  border: 1px solid #38a169;
  color: #22543d;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.flash-error {
  background: #fdecec;
  border: 1px solid #e53e3e;
  color: #822727;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.badge-status {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.badge-ontime {
  background: #e6f6ec;
  color: #22543d;
}

.badge-late {
  background: #fdecec;
  color: #822727;
}

form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 560px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-row label {
  font-weight: 600;
  font-size: 0.9rem;
}

.form-row input,
.form-row select,
.form-row textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}

.readonly-field {
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.summary-box {
  background: var(--bg);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-primary:disabled {
  background: #999;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  max-width: none;
}

.inline-form input,
.inline-form select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.tab-links {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tab-links a {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--brand);
  background: #fff;
  border: 1px solid var(--border);
}

.tab-links a.tab-active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

table.data-table th,
table.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table.data-table th {
  background: var(--bg);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.counter-box {
  font-weight: 600;
  margin-bottom: 1rem;
}

.banner-warn {
  background: #fff8e1;
  border: 1px solid #d69e2e;
  color: #744210;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.row-na input[type="number"] {
  background: #f0f0f0;
}

.reconciliation {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 560px;
  margin-top: 1.5rem;
}

.reconciliation .anomali {
  color: #c53030;
  font-weight: 700;
}

.reconciliation .baseline {
  color: #666;
  font-style: italic;
}

@media (max-width: 768px) {
  .sidebar-toggle {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 10;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .content {
    padding: 4rem 1rem 1.5rem;
  }
}
