:root {
  --green-950: #062319;
  --green-900: #0b3525;
  --green-800: #175d3d;
  --green-100: #e8f4ed;
  --red-800: #861827;
  --red-600: #c9273b;
  --red-100: #fdecef;
  --gold: #c99b42;
  --ink: #152019;
  --muted: #647168;
  --line: #dce5df;
  --surface: #ffffff;
  --canvas: #f3f6f4;
  --shadow: 0 24px 70px rgba(6, 35, 25, .13);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; }
body { color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 0; min-height: 100vh; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.login-body {
  background: var(--green-950);
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100vh;
  padding: 1rem;
  position: relative;
}

.login-body::before {
  background:
    linear-gradient(105deg, rgba(4, 15, 11, .96), rgba(6, 35, 25, .87) 50%, rgba(6, 35, 25, .5) 73%, rgba(134, 24, 39, .62)),
    url("coffee-farm.jpg") 70% center / cover no-repeat;
  content: "";
  inset: 0;
  position: fixed;
  z-index: -2;
}

.login-body::after {
  background:
    radial-gradient(circle at 82% 12%, rgba(201, 39, 59, .25), transparent 28rem),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: auto, 48px 48px, 48px 48px;
  content: "";
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: -1;
}

.back-link {
  background: rgba(5, 10, 7, .64);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: #fff;
  font-size: .76rem;
  font-weight: 750;
  left: 1rem;
  padding: .6rem .82rem;
  position: fixed;
  text-decoration: none;
  top: 1rem;
}

.login-wrap { align-items: center; display: flex; justify-content: center; padding: 3.5rem 0 1.2rem; }
.login-card {
  background: rgba(255,255,255,.98);
  border-radius: 24px;
  box-shadow: 0 34px 90px rgba(0,0,0,.42);
  max-width: 440px;
  padding: clamp(1.4rem, 4vw, 2.15rem);
  width: min(100%, 440px);
}
.login-logo { border-radius: 50%; box-shadow: 0 10px 22px rgba(6,35,25,.16); display: block; height: 60px; margin-bottom: 1rem; object-fit: cover; width: 60px; }
.eyebrow { color: var(--red-800); font-size: .7rem; font-weight: 850; letter-spacing: .15em; margin: 0 0 .4rem; text-transform: uppercase; }
.login-card h1 { color: var(--green-950); font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.15rem, 7vw, 3rem); letter-spacing: -.04em; line-height: 1; margin: 0 0 .75rem; }
.login-intro { color: var(--muted); font-size: .9rem; line-height: 1.5; margin: 0 0 1rem; }
.login-card form, .form-panel form, .setup-card form { display: grid; gap: .75rem; }
label { color: var(--green-950); display: grid; font-size: .74rem; font-weight: 800; gap: .38rem; letter-spacing: .055em; text-transform: uppercase; }
input, select, textarea {
  background: #f9fbfa;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  min-height: 46px;
  outline: none;
  padding: .75rem .85rem;
  text-transform: none;
  width: 100%;
}
textarea { line-height: 1.55; min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { background: #fff; border-color: var(--green-800); box-shadow: 0 0 0 4px rgba(23,93,61,.11); }
input[type="checkbox"] { min-height: auto; width: auto; }
input[type="file"] { background: #fff; padding: .65rem; }
label small { color: var(--muted); font-size: .7rem; font-weight: 500; letter-spacing: 0; line-height: 1.45; text-transform: none; }
.password-control { display: grid; grid-template-columns: 1fr auto; }
.password-control input { border-radius: 11px 0 0 11px; }
.password-control button { background: #f1f5f2; border: 1px solid var(--line); border-left: 0; border-radius: 0 11px 11px 0; color: var(--red-800); cursor: pointer; font-size: .75rem; font-weight: 800; padding: 0 .8rem; }
.remember { align-items: center; color: var(--muted); display: flex; font-size: .72rem; font-weight: 600; gap: .5rem; letter-spacing: 0; text-transform: none; }

.button {
  align-items: center;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 46px;
  padding: .75rem 1rem;
  text-decoration: none;
}
.button.primary { background: linear-gradient(135deg, var(--red-600), var(--red-800)); box-shadow: 0 12px 24px rgba(134,24,39,.2); color: #fff; }
.button.secondary { background: var(--green-100); color: var(--green-900); }
.button.danger { background: #fff0f1; border: 1px solid rgba(134,24,39,.18); color: var(--red-800); }
.button.small { font-size: .75rem; min-height: 38px; padding: .55rem .75rem; }
.button.wide { width: 100%; }
.security-note { background: var(--green-100); border: 1px solid rgba(23,93,61,.1); border-radius: 11px; display: grid; gap: .15rem; margin-top: .9rem; padding: .68rem .8rem; }
.security-note strong { color: var(--green-950); font-size: .75rem; }
.security-note span, .help-link { color: var(--muted); font-size: .7rem; line-height: 1.45; }
.help-link { display: inline-block; margin-top: .75rem; }
.login-footer { color: rgba(255,255,255,.62); font-size: .68rem; padding: .5rem; text-align: center; }

.alert { border: 1px solid transparent; border-radius: 11px; font-size: .82rem; line-height: 1.5; margin-bottom: 1rem; padding: .72rem .85rem; }
.alert.success { background: var(--green-100); border-color: rgba(23,93,61,.15); color: var(--green-900); }
.alert.error { background: var(--red-100); border-color: rgba(134,24,39,.16); color: var(--red-800); }
.alert.warning { background: #fff6d8; border-color: #efd68c; color: #624b0e; }

.portal-body { background: var(--canvas); }
.portal-shell { display: grid; grid-template-columns: 245px minmax(0,1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--green-950), #03150f);
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 1.1rem;
  position: sticky;
  top: 0;
}
.portal-brand { align-items: center; display: flex; gap: .75rem; padding: .4rem .3rem 1.4rem; text-decoration: none; }
.portal-brand img { border-radius: 50%; height: 46px; width: 46px; }
.portal-brand span { display: grid; }
.portal-brand strong { font-size: .88rem; }
.portal-brand small { color: rgba(255,255,255,.62); font-size: .7rem; margin-top: .14rem; }
.sidebar nav { display: grid; gap: .25rem; }
.sidebar nav a { border-radius: 10px; color: rgba(255,255,255,.72); font-size: .82rem; font-weight: 700; padding: .75rem .85rem; text-decoration: none; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar nav a.active { box-shadow: inset 3px 0 var(--red-600); }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.1); display: grid; margin-top: auto; padding: 1rem .35rem .2rem; }
.sidebar-footer span { font-size: .78rem; font-weight: 800; }
.sidebar-footer small { color: rgba(255,255,255,.55); font-size: .66rem; margin: .15rem 0 .65rem; }
.sidebar-footer a { color: #fff; font-size: .72rem; }

.portal-main { min-width: 0; }
.topbar { align-items: center; background: rgba(255,255,255,.93); border-bottom: 1px solid var(--line); display: flex; gap: 1rem; justify-content: space-between; padding: 1.1rem clamp(1rem, 3vw, 2.2rem); position: sticky; top: 0; z-index: 5; }
.topbar h1 { color: var(--green-950); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.55rem, 3vw, 2.1rem); margin: 0; }
.topbar .eyebrow { margin-bottom: .18rem; }
.public-site-link { border: 1px solid var(--line); border-radius: 999px; color: var(--green-900); font-size: .72rem; font-weight: 800; padding: .55rem .75rem; text-decoration: none; }
.menu-toggle { display: none; }
.portal-content { margin: 0 auto; max-width: 1450px; padding: clamp(1rem, 3vw, 2.2rem); }

.welcome-panel { align-items: center; background: linear-gradient(125deg, var(--green-900), var(--green-800)); border-radius: 18px; color: #fff; display: flex; justify-content: space-between; margin-bottom: 1rem; padding: clamp(1.15rem,3vw,1.8rem); }
.welcome-panel h2 { font-family: Georgia, "Times New Roman", serif; font-size: 2rem; margin: 0 0 .35rem; }
.welcome-panel p { color: rgba(255,255,255,.72); margin: 0; }
.welcome-panel .eyebrow { color: #efc56f; }
.welcome-panel > span { background: rgba(255,255,255,.11); border: 1px solid rgba(255,255,255,.16); border-radius: 999px; font-size: .72rem; font-weight: 800; padding: .6rem .8rem; }
.stat-grid { display: grid; gap: .8rem; grid-template-columns: repeat(4,minmax(0,1fr)); margin-bottom: 1rem; }
.stat-grid article, .panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 30px rgba(6,35,25,.04); }
.stat-grid article { display: grid; gap: .25rem; padding: 1.1rem; }
.stat-grid strong { color: var(--green-950); font-family: Georgia, "Times New Roman", serif; font-size: 1.9rem; }
.stat-grid span { color: var(--muted); font-size: .74rem; }
.dashboard-grid, .two-column, .profile-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0,1.25fr) minmax(320px,.75fr); }
.panel { padding: clamp(1rem,2.4vw,1.45rem); }
.panel-heading { align-items: center; display: flex; gap: 1rem; justify-content: space-between; margin-bottom: 1rem; }
.panel-heading h2, .form-panel h2 { color: var(--green-950); font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; margin: 0; }
.panel-heading > span, .panel-heading > a { color: var(--red-800); font-size: .72rem; font-weight: 800; }
.action-grid { display: grid; gap: .7rem; grid-template-columns: repeat(2,minmax(0,1fr)); }
.action-grid a { background: var(--canvas); border: 1px solid var(--line); border-radius: 12px; display: grid; gap: .25rem; padding: .9rem; text-decoration: none; }
.action-grid a:hover { border-color: var(--green-800); transform: translateY(-1px); }
.action-grid strong { color: var(--green-950); font-size: .82rem; }
.action-grid span, .empty-copy { color: var(--muted); font-size: .72rem; line-height: 1.45; }
.activity-list, .simple-list, .user-list, .document-list { display: grid; }
.activity-list > div, .simple-list article { border-top: 1px solid var(--line); display: grid; gap: .2rem; padding: .72rem 0; }
.simple-list article { align-items: center; gap: .75rem; grid-template-columns: minmax(0,1fr) auto; }
.simple-list article > div:first-child { display: grid; gap: .2rem; min-width: 0; }
.activity-list > div:first-child, .simple-list article:first-child { border-top: 0; }
.activity-list strong, .simple-list strong { font-size: .78rem; }
.activity-list span, .simple-list span { color: var(--muted); font-size: .68rem; }

.form-panel > .eyebrow { margin-bottom: .3rem; }
.form-panel > h2 { margin-bottom: 1rem; }
.form-panel form { gap: .9rem; }
.form-grid { display: grid; gap: .8rem; grid-template-columns: repeat(2,minmax(0,1fr)); }
.form-actions, .management-actions { align-items: center; display: flex; flex-wrap: wrap; gap: .5rem; }
.management-actions { justify-content: flex-end; }
.management-actions form { display: block; margin: 0; }
.picking-schedule-panel { margin-bottom: 1rem; }
.picking-schedule-panel form { display: grid; gap: 1rem; }
.portal-table-wrap { border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.portal-table { border-collapse: collapse; min-width: 720px; width: 100%; }
.portal-table th, .portal-table td { border-bottom: 1px solid var(--line); padding: .7rem .8rem; text-align: left; vertical-align: middle; }
.portal-table thead th { background: var(--green-950); color: #fff; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.portal-table tbody th { color: var(--green-950); font-size: .76rem; white-space: nowrap; }
.portal-table tbody td:last-child { color: var(--muted); font-size: .68rem; white-space: nowrap; }
.portal-table tbody tr:last-child th, .portal-table tbody tr:last-child td { border-bottom: 0; }
.portal-table input { min-width: 250px; }
.factory-notice-layout { align-items: start; }
.factory-notice-list article { align-items: flex-start; }
.partner-current-logo {
  align-items: center;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  gap: 1rem;
  padding: .8rem;
}
.partner-current-logo span { color: var(--muted); font-size: .7rem; font-weight: 800; }
.partner-current-logo img { background: #fff; border-radius: 8px; height: 64px; object-fit: contain; padding: .4rem; width: 120px; }
.partner-list article { align-items: center; }
.partner-list-identity { align-items: center; display: flex !important; gap: .75rem !important; }
.partner-list-identity > img { background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; height: 52px; object-fit: contain; padding: .3rem; width: 76px; }
.partner-list-identity > div { display: grid; gap: .2rem; min-width: 0; }
.partner-logo-placeholder { align-items: center; background: var(--canvas); border-radius: 8px; color: var(--muted); display: flex; font-size: .6rem; height: 52px; justify-content: center; width: 76px; }
.document-list article { align-items: center; border-top: 1px solid var(--line); display: flex; gap: 1rem; justify-content: space-between; padding: .8rem 0; }
.document-list article:first-child { border-top: 0; }
.document-list article > div { align-items: center; display: flex; gap: .7rem; min-width: 0; }
.document-list article > div > div { display: grid; gap: .2rem; min-width: 0; }
.document-list strong { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-list small { color: var(--muted); font-size: .68rem; }
.file-mark { background: var(--red-100); border-radius: 8px; color: var(--red-800); font-size: .58rem; font-weight: 900; padding: .55rem .35rem; }
.empty-state { background: var(--canvas); border: 1px dashed #bfcbc3; border-radius: 12px; display: grid; gap: .25rem; padding: 1rem; }
.empty-state strong { color: var(--green-950); }
.empty-state span { color: var(--muted); font-size: .75rem; }

.user-list article { align-items: center; border-top: 1px solid var(--line); display: grid; gap: .7rem; grid-template-columns: auto 1fr auto; padding: .75rem 0; }
.user-list article:first-child { border-top: 0; }
.user-list article > span, .profile-card > span { align-items: center; background: var(--green-100); border-radius: 50%; color: var(--green-900); display: flex; font-size: .68rem; font-weight: 900; height: 38px; justify-content: center; width: 38px; }
.user-list article > div { display: grid; gap: .15rem; }
.user-list strong { font-size: .78rem; }
.user-list small { color: var(--muted); font-size: .66rem; }
.user-list em { color: var(--red-800); font-size: .62rem; }
.profile-layout { grid-template-columns: minmax(260px,.55fr) minmax(0,1fr); }
.profile-card { align-self: start; text-align: center; }
.profile-card > span { height: 64px; margin: 0 auto .8rem; width: 64px; }
.profile-card h2 { color: var(--green-950); font-family: Georgia, "Times New Roman", serif; margin: 0; }
.profile-card p { color: var(--muted); font-size: .75rem; }
.profile-card dl { display: grid; margin: 1rem 0 0; text-align: left; }
.profile-card dl div { border-top: 1px solid var(--line); display: flex; justify-content: space-between; padding: .7rem 0; }
.profile-card dt { color: var(--muted); font-size: .7rem; }
.profile-card dd { font-size: .72rem; font-weight: 800; margin: 0; }

.setup-body { align-items: center; background: var(--canvas); display: flex; justify-content: center; padding: 1rem; }
.setup-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow); max-width: 430px; padding: 2rem; width: 100%; }
.setup-card img { border-radius: 50%; height: 64px; margin-bottom: 1rem; width: 64px; }
.setup-card h1 { color: var(--green-950); font-family: Georgia, "Times New Roman", serif; margin: 0 0 1rem; }

@media (max-width: 980px) {
  .portal-shell { grid-template-columns: 1fr; }
  .sidebar { bottom: 0; box-shadow: 16px 0 40px rgba(0,0,0,.22); left: 0; max-width: 265px; position: fixed; top: 0; transform: translateX(-105%); transition: transform .2s ease; width: 86vw; z-index: 20; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { background: var(--green-100); border: 0; border-radius: 9px; color: var(--green-900); display: block; font-size: .72rem; font-weight: 800; padding: .6rem .75rem; }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-grid, .two-column { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .login-body { padding: .7rem; }
  .back-link { left: .7rem; top: .7rem; }
  .login-wrap { padding-top: 3.6rem; }
  .login-card { border-radius: 20px; }
  .topbar { align-items: flex-start; }
  .topbar .public-site-link { display: none; }
  .portal-content { padding: .85rem; }
  .welcome-panel { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .stat-grid, .action-grid, .form-grid, .profile-layout { grid-template-columns: 1fr; }
  .simple-list article { align-items: flex-start; grid-template-columns: 1fr; }
  .management-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); justify-content: stretch; width: 100%; }
  .management-actions .button { width: 100%; }
  .document-list article { align-items: flex-start; flex-direction: column; }
  .document-list .management-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: .001ms !important; }
}
