/* ==========================================================================
   PANICOM AI — ระบบบัญชีบริษัท
   Design tokens matched to the real panicom-ai brand site: soft blue accent
   (#5B8CFF), near-black surfaces (#0A0C10 / #12151B / #181C24), IBM Plex
   Sans Thai (body) + IBM Plex Mono (logo/technical accents).
   ========================================================================== */

:root {
  --brand-blue: #5B8CFF;
  --brand-blue-dark: #3E6BFF;
  --brand-blue-darker: #2B4FDE;
  --brand-navy: #0A0C10;
  --brand-navy-2: #12151B;
  --brand-navy-3: #181C24;
  --brand-cyan: #5B8CFF;

  --ink-900: #12151B;
  --ink-700: #3A3F4A;
  --ink-500: #71767E;
  --ink-300: #AEB3BB;

  --surface-0: #F5F6F8;
  --surface-1: #FFFFFF;
  --surface-2: #EEF1F5;
  --border-soft: #E3E6EB;

  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;

  --radius-lg: 10px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(10, 12, 16, 0.04), 0 8px 24px -12px rgba(10, 12, 16, 0.12);
  --shadow-card-hover: 0 4px 10px rgba(10, 12, 16, 0.06), 0 16px 32px -12px rgba(10, 12, 16, 0.18);
  --font-display: 'IBM Plex Mono', 'IBM Plex Sans Thai', monospace;
  --font-body: 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--surface-0);
  background-image:
    radial-gradient(1200px 500px at 100% -10%, rgba(91, 140, 255, 0.06), transparent),
    radial-gradient(900px 400px at -10% 0%, rgba(91, 140, 255, 0.04), transparent);
  background-attachment: fixed;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.fw-bold, .fw-semibold {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

/* ---------------------------------------------------------------------- */
/* Navbar + brand mark                                                    */
/* ---------------------------------------------------------------------- */
.app-navbar {
  background: linear-gradient(100deg, var(--brand-navy) 0%, var(--brand-navy-2) 65%, var(--brand-navy-3) 100%);
  padding-top: .7rem;
  padding-bottom: .7rem;
  box-shadow: 0 4px 24px rgba(5, 6, 10, 0.35);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.brand-logo-img {
  height: 26px;
  width: auto;
  display: block;
}

.app-navbar .nav-link {
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  font-size: .93rem;
  padding: .5rem .85rem;
  border-radius: var(--radius-sm);
  transition: color .15s ease, background-color .15s ease;
}
.app-navbar .nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.app-navbar .nav-link.active { color: #fff; background: rgba(91, 140, 255, 0.28); }
.app-navbar .dropdown-menu {
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card-hover);
  padding: .4rem;
  margin-top: .5rem;
}
.app-navbar .dropdown-item {
  border-radius: var(--radius-sm);
  font-size: .92rem;
  padding: .5rem .75rem;
}
.app-navbar .dropdown-item:hover { background: var(--surface-2); }
.app-navbar .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.3);
}
.app-navbar .navbar-toggler-icon {
  filter: invert(1);
}

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-darker));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  font-family: var(--font-display);
}

.role-pill {
  font-size: .68rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 999px;
  letter-spacing: .02em;
}
.role-pill-admin { background: #fff; color: var(--brand-navy); }
.role-pill-purchasing { background: rgba(217, 119, 6, 0.18); color: #fbbf6b; }
.role-pill-ap { background: rgba(220, 38, 38, 0.2); color: #fca5a5; }
.role-pill-ar { background: rgba(22, 163, 74, 0.2); color: #86efac; }

/* ---------------------------------------------------------------------- */
/* Cards                                                                   */
/* ---------------------------------------------------------------------- */
.card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  background: var(--surface-1);
}

h4.fw-bold {
  color: var(--ink-900);
  font-size: 1.4rem;
}
h5.fw-bold, h6.fw-semibold {
  color: var(--ink-900);
}

/* ---------------------------------------------------------------------- */
/* Stat cards                                                             */
/* ---------------------------------------------------------------------- */
.stat-card {
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120px 80px at 100% 0%, rgba(255,255,255,0.18), transparent);
  pointer-events: none;
}
.stat-card .stat-label { font-size: .82rem; opacity: .85; font-weight: 500; position: relative; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 1.65rem; font-weight: 700; position: relative; margin-top: .15rem; }

.stat-income { background: linear-gradient(135deg, #16a34a, #0d7a37); }
.stat-expense { background: linear-gradient(135deg, #dc2626, #a91d1d); }
.stat-net { background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-darker)); }
.stat-neutral { background: linear-gradient(135deg, #475569, #262e42); }
.stat-balance { background: linear-gradient(135deg, #7c3aed, #4c1d95); }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */
.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  font-size: .92rem;
}
.btn-primary {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(91, 140, 255, 0.3);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-blue-dark);
  border-color: var(--brand-blue-dark);
}
.btn-outline-primary {
  color: var(--brand-blue);
  border-color: var(--brand-blue);
}
.btn-outline-primary:hover {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
}
.btn-outline-secondary {
  color: var(--ink-700);
  border-color: var(--border-soft);
}
.btn-outline-secondary:hover {
  background: var(--surface-2);
  color: var(--ink-900);
  border-color: var(--border-soft);
}

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */
.table thead th {
  background: var(--brand-navy);
  color: #fff;
  font-weight: 500;
  font-size: .82rem;
  white-space: nowrap;
  border: none;
  letter-spacing: .01em;
}
.table tbody tr:hover { background: var(--surface-2); }
.table-hover > tbody > tr:hover > * { background-color: var(--surface-2); }
.table td, .table th { vertical-align: middle; }

.badge-category {
  padding: .35em .7em;
  border-radius: 999px;
  color: #fff;
  font-size: .78rem;
  font-weight: 500;
}

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */
.form-label { font-weight: 500; color: var(--ink-700); font-size: .9rem; }
.form-control, .form-select {
  border-color: var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: .93rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 .2rem rgba(91, 140, 255, 0.18);
}
.form-text { color: var(--ink-500); font-size: .8rem; }

.filter-adv-toggle {
  color: var(--brand-blue);
  font-weight: 500;
  font-size: .85rem;
  text-decoration: none;
}
.filter-adv-toggle:hover { color: var(--brand-blue-dark); }
.filter-adv-caret { display: inline-block; transition: transform .15s ease; }
.filter-adv-toggle.collapsed .filter-adv-caret { transform: rotate(-90deg); }

/* ---------------------------------------------------------------------- */
/* Alerts                                                                  */
/* ---------------------------------------------------------------------- */
.alert { border: none; border-radius: var(--radius-md); }
.alert-danger { background: #fef2f2; color: #991b1b; }
.alert-success { background: #f0fdf4; color: #166534; }

/* ---------------------------------------------------------------------- */
/* Login page                                                              */
/* ---------------------------------------------------------------------- */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(91, 140, 255, 0.16), transparent),
    radial-gradient(1100px 700px at 85% 90%, rgba(91, 140, 255, 0.22), transparent),
    linear-gradient(135deg, var(--brand-navy), var(--brand-navy-2) 55%, var(--brand-navy-3));
  padding: 1.5rem;
}
.login-card {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 14px;
  padding: 2.75rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 60px -20px rgba(5, 6, 10, 0.55);
}
.login-brand {
  text-align: center;
  line-height: 1;
}
.login-logo-img {
  max-width: 100%;
  height: auto;
  max-height: 40px;
  width: auto;
  margin: 0 auto;
  display: block;
}
.login-tagline { color: var(--ink-500); font-size: .88rem; text-align: center; margin-top: .75rem; }

/* ---------------------------------------------------------------------- */
/* Misc                                                                     */
/* ---------------------------------------------------------------------- */
.dropdown-menu { border: none; border-radius: var(--radius-md); box-shadow: var(--shadow-card-hover); }
.badge.text-bg-dark { background: var(--brand-navy) !important; }

/* ---------------------------------------------------------------------- */
/* Excel-style month tab bar (sticky at bottom, like spreadsheet sheet tabs) */
/* ---------------------------------------------------------------------- */
.excel-tabbar-spacer { height: 58px; }
.excel-tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface-1);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -4px 16px rgba(10, 12, 16, 0.07);
  z-index: 1020;
}
.excel-tabbar-inner {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .55rem 1rem;
  max-width: 100%;
}
.excel-tab-nav {
  flex: 0 0 auto;
  color: var(--ink-500);
  font-weight: 700;
  font-size: .95rem;
  padding: .3rem .55rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  line-height: 1;
}
.excel-tab-nav:hover { background: var(--surface-2); color: var(--ink-900); }
.excel-tabs {
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
}
.excel-tab {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink-500);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: .42rem .75rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.excel-tab:hover { background: #fff; color: var(--ink-900); border-color: var(--ink-300); }
.excel-tab.active {
  background: var(--brand-blue);
  color: #fff;
  border-color: var(--brand-blue);
  box-shadow: 0 2px 6px rgba(91, 140, 255, 0.35);
}
.excel-tab-all {
  border-left: 2px solid var(--border-soft);
  margin-left: .35rem;
  padding-left: .85rem;
}
.excel-tabbar-year {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink-700);
  font-size: .82rem;
  padding: 0 .25rem 0 .6rem;
  border-left: 1px solid var(--border-soft);
  margin-left: .25rem;
}
@media (max-width: 768px) {
  .excel-tabbar-year { display: none; }
}
