/* BRD ERP — kkfoils-inspired navy/teal theme */
:root {
  --navy: #0c2c3d;
  --navy-2: #14384c;
  --teal: #0d7a5c;
  --teal-2: #0b6a50;
  --bg: #eef4f1;
  --card: #ffffff;
  --text: #1a2b33;
  --muted: #5b6b73;
  --border: #d5e0db;
  --blue: #1e6fd9;
  --blue-2: #1557ad;
  --orange: #e67e22;
  --orange-2: #c96a16;
  --danger: #c0392b;
  --ok: #1e8a5a;
  --shadow: 0 8px 24px rgba(12, 44, 61, 0.08);
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, #e8f2ee 0%, var(--bg) 240px);
  min-height: 100vh;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.top-nav {
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-2) 60%, #0d4a3a 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.top-nav-brand .brand-link { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.brand-logo-fallback {
  width: 42px; height: 42px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), #19a57a);
  display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
}
.brand-name { font-weight: 700; display: block; line-height: 1.1; }
.brand-text small { opacity: .8; font-size: .75rem; }

.nav-toggle {
  display: none; background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px; padding: .4rem .7rem; cursor: pointer;
}
.top-menu { display: flex; align-items: center; gap: .25rem; flex: 1; flex-wrap: wrap; }
.top-menu-item { position: relative; }
.top-menu-btn, .top-menu > a.nav-link {
  background: transparent; border: 0; color: #e8f3ef; font: inherit; font-weight: 600;
  padding: .45rem .7rem; border-radius: 8px; cursor: pointer;
}
.top-menu-btn:hover, .top-menu > a.nav-link:hover, .top-menu > a.nav-link.active {
  background: rgba(255,255,255,.12); color: #fff; text-decoration: none;
}
.top-submenu {
  display: none; position: absolute; top: 100%; left: 0; min-width: 220px;
  background: #fff; color: var(--text); border-radius: 10px; box-shadow: var(--shadow);
  padding: .4rem; z-index: 60; border: 1px solid var(--border);
}
.top-menu-item:hover > .top-submenu, .top-menu-item:focus-within > .top-submenu { display: block; }
.top-submenu a {
  display: block; padding: .5rem .7rem; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500;
}
.top-submenu a:hover { background: #eef8f3; color: var(--teal); }
.top-nav-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.top-nav-user .role-pill {
  background: rgba(13,122,92,.35); border: 1px solid rgba(255,255,255,.2);
  padding: .2rem .55rem; border-radius: 999px; font-size: .75rem;
}
.btn-logout {
  background: #e67e22; color: #fff; border: 0; border-radius: 8px; padding: .4rem .7rem;
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn-logout:hover { background: var(--orange-2); text-decoration: none; color: #fff; }

.main { width: min(1200px, calc(100% - 2rem)); margin: 1.1rem auto 2rem; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.45rem; color: var(--navy); }
.muted { color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.card-title { margin: 0 0 .75rem; color: var(--navy); font-size: 1.05rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-block; }
  .top-menu { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  .top-menu.open { display: flex; }
  .top-submenu { position: static; box-shadow: none; border: 0; }
}

.kpi {
  background: linear-gradient(160deg, #fff 0%, #f3faf7 100%);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem;
  box-shadow: var(--shadow);
}
.kpi .label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.kpi .value { font-size: 1.7rem; font-weight: 800; color: var(--navy); margin-top: .25rem; }
.kpi.teal { border-top: 4px solid var(--teal); }
.kpi.blue { border-top: 4px solid var(--blue); }
.kpi.orange { border-top: 4px solid var(--orange); }
.kpi.navy { border-top: 4px solid var(--navy); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 0; border-radius: 9px; padding: .5rem .9rem; font-weight: 700; cursor: pointer;
  text-decoration: none; font: inherit; color: #fff;
}
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn-teal { background: var(--teal); }
.btn-teal:hover { background: var(--teal-2); color: #fff; }
.btn-blue { background: var(--blue); }
.btn-blue:hover { background: var(--blue-2); color: #fff; }
.btn-orange { background: var(--orange); }
.btn-orange:hover { background: var(--orange-2); color: #fff; }
.btn-navy { background: var(--navy); }
.btn-ghost { background: #eef3f1; color: var(--navy); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: .35rem .65rem; font-size: .85rem; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: .92rem;
}
table.data th, table.data td {
  padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top;
}
table.data th { background: #f2f7f5; color: var(--navy); font-weight: 700; white-space: nowrap; }
table.data tr:hover td { background: #f8fcfa; }
.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700;
}
.badge-ok { background: #e5f7ee; color: var(--ok); }
.badge-warn { background: #fff3e6; color: #b86100; }
.badge-err { background: #fdecea; color: var(--danger); }
.badge-info { background: #e8f1fc; color: var(--blue); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .85rem 1rem; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-weight: 600; font-size: .88rem; color: var(--navy); }
.form-group input, .form-group select, .form-group textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; font: inherit; background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: 2px solid rgba(13,122,92,.25); border-color: var(--teal);
}
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; }
.alert-ok { background: #e5f7ee; color: var(--ok); border: 1px solid #bfe8d1; }
.alert-err { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }

/* Login */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(circle at 15% 20%, rgba(13,122,92,.25), transparent 35%),
    radial-gradient(circle at 85% 10%, rgba(30,111,217,.22), transparent 30%),
    radial-gradient(circle at 70% 80%, rgba(230,126,34,.18), transparent 35%),
    linear-gradient(135deg, #0c2c3d 0%, #0d4a3a 45%, #0d7a5c 100%);
  background: linear-gradient(135deg, #0c2c3d 0%, #0f3d4f 40%, #0d5a45 100%);
}
.login-card {
  width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 1.6rem 1.5rem 1.4rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.28);
}
.login-brand { text-align: center; margin-bottom: 1.2rem; }
.login-brand .logo {
  width: 64px; height: 64px; margin: 0 auto .7rem; border-radius: 16px;
  background: linear-gradient(135deg, var(--teal), #1e6fd9); color: #fff;
  display: grid; place-items: center; font-weight: 900; font-size: 1.2rem;
}
.login-brand h1 { margin: 0; color: var(--navy); font-size: 1.35rem; }
.login-brand p { margin: .35rem 0 0; color: var(--muted); }
.login-card .btn { width: 100%; margin-top: .4rem; }
.login-hint { margin-top: 1rem; font-size: .82rem; color: var(--muted); text-align: center; }

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: .8rem; }
.filters .form-group { min-width: 140px; }

@media print {
  .top-nav, .toolbar, .btn, .actions, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .main { width: 100%; margin: 0; }
}


/* Branding: portrait logo */
.brand-portrait {
  width: 42px; height: 42px; border-radius: 10px; object-fit: cover;
  border: 1px solid rgba(255,255,255,.25); background: #fff;
}
.login-brand .login-portrait {
  width: 120px; height: 120px; border-radius: 20px; object-fit: cover;
  margin: 0 auto .7rem; display: block;
  box-shadow: 0 8px 24px rgba(12,44,61,.25);
  border: 3px solid #e8f3ef;
}
.login-brand .login-company { font-weight: 700; color: var(--navy); margin-top: .15rem; }
.login-brand .logo { display: none; } /* legacy text logo */

.actions-cell { display: flex; flex-wrap: wrap; gap: .35rem; }
.num-sm { width: 110px; max-width: 100%; }

/* Mobile entry improvements */
@media (max-width: 700px) {
  .main { width: calc(100% - 1rem); margin: .75rem auto 5rem; }
  .page-head h1 { font-size: 1.25rem; }
  .btn, .top-menu-btn, .nav-toggle, .btn-logout {
    min-height: 44px; padding: .65rem 1rem;
  }
  .btn-sm { min-height: 40px; padding: .5rem .75rem; font-size: .9rem; }
  .form-group input, .form-group select, .form-group textarea {
    font-size: 16px; padding: .7rem .75rem; min-height: 44px;
  }
  .form-grid { grid-template-columns: 1fr; gap: .75rem; }
  .tx-form .actions, .sticky-actions {
    position: sticky; bottom: 0; z-index: 20;
    background: rgba(255,255,255,.96); border-top: 1px solid var(--border);
    padding: .75rem; margin: 1rem -1.1rem -1rem; box-shadow: 0 -6px 16px rgba(0,0,0,.06);
  }
  .btn-block-mobile, .sticky-actions .btn { width: 100%; }
  table.data th, table.data td { padding: .65rem .55rem; }
  .toolbar .btn { flex: 1 1 auto; }
  .top-nav { flex-wrap: wrap; gap: .5rem; }
  .top-nav-user { margin-left: 0; width: 100%; justify-content: space-between; }
  .kpi .value { font-size: 1.45rem; }
}
