body{font-family:Arial,sans-serif;margin:20px;} .nav{margin-bottom:12px;} table{border-collapse:collapse;width:100%;font-size:13px;} th,td{border:1px solid #ddd;padding:6px;} th{background:#f4f4f4;} .err{color:#b00020;} .ok{color:#0a7f31;} input,select,button,textarea{margin-right:8px;padding:6px;} textarea{font-family:inherit;} .filters,.sync{margin:10px 0;} pre{white-space:pre-wrap;word-break:break-all;background:#fafafa;border:1px solid #ddd;padding:10px;} .box{max-width:360px;margin:80px auto;border:1px solid #ddd;padding:20px;}
.orders-nav{display:flex;align-items:center;justify-content:space-between;gap:24px;min-height:32px;}
/* Login layout stays usable on narrow screens and with the keyboard open. */
body.login-page{margin:0;min-height:100vh;min-height:100dvh;box-sizing:border-box;display:flex;flex-direction:column;padding:clamp(24px,8vh,80px) 16px;background:#f8fafc;color:#1f2937;}
.login-page .login-card{box-sizing:border-box;width:100%;max-width:404px;margin:0 auto;padding:28px;background:#fff;border:1px solid #e5e7eb;border-radius:12px;box-shadow:0 8px 24px rgba(15,23,42,.06);}
.login-card h1{margin:0 0 24px;font-size:24px;line-height:1.4;overflow-wrap:anywhere;}
.login-form{display:flex;flex-direction:column;gap:20px;}
.login-field{display:flex;flex-direction:column;gap:8px;min-width:0;}
.login-field label{font-size:14px;font-weight:600;}
.login-form input,.login-form button{box-sizing:border-box;width:100%;min-width:0;min-height:48px;margin:0;padding:12px;font:inherit;font-size:16px;line-height:1.5;border:1px solid #94a3b8;border-radius:8px;}
.login-form input{background:#fff;color:#1f2937;}
.login-form input::placeholder{color:#64748b;}
.login-form button{background:#2563eb;border-color:#2563eb;color:#fff;font-weight:600;cursor:pointer;touch-action:manipulation;}
.login-form button:hover{background:#1d4ed8;border-color:#1d4ed8;}
.login-form input:focus-visible,.login-form button:focus-visible{outline:3px solid #60a5fa;outline-offset:2px;}
.login-card .login-error{margin:0 0 20px;padding:12px;border:1px solid #fecaca;border-radius:8px;background:#fff1f2;line-height:1.5;overflow-wrap:anywhere;}
@media (max-width:360px){.login-page .login-card{padding:20px;}.login-card h1{font-size:22px;}}
.orders-nav-left{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.orders-nav a,.orders-nav a:hover{text-decoration:none;}
.orders-nav a{color:#1f2937;}
.orders-nav a:hover{color:#2563eb;}
.nav-separator{color:#9ca3af;}
.user-menu{position:relative;margin-left:auto;}
.user-menu summary{display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:6px;cursor:pointer;font-weight:600;list-style:none;user-select:none;}
.user-menu summary::-webkit-details-marker{display:none;}
.user-menu summary::after{content:"▾";font-size:11px;color:#6b7280;}
.user-menu[open] summary{background:#f3f4f6;}
.user-menu-dropdown{position:absolute;right:0;top:calc(100% + 5px);z-index:20;display:flex;min-width:120px;flex-direction:column;padding:6px;background:#fff;border:1px solid #e5e7eb;border-radius:8px;box-shadow:0 10px 25px rgba(0,0,0,.12);}
.user-menu-dropdown a{display:block;padding:8px 10px;border-radius:5px;white-space:nowrap;}
.user-menu-dropdown a:hover{background:#f3f4f6;}
.country-badge{display:inline-flex;align-items:center;gap:4px;white-space:nowrap;}
.flag-icon{width:16px;height:12px;object-fit:cover;border:1px solid #ddd;vertical-align:middle;}
.orders-page .customer-identity{display:grid;grid-template-columns:minmax(0,1fr);gap:2px 8px;align-items:center;min-width:0;}
.orders-page .customer-identity-with-flag{grid-template-columns:48px minmax(0,1fr);}
.orders-page .customer-flag{grid-column:1;grid-row:1 / span 2;width:48px;height:36px;object-fit:contain;box-sizing:border-box;align-self:center;}
.orders-page .customer-identity-with-flag .customer-country{grid-column:2;grid-row:1;}
.orders-page .customer-identity-with-flag .customer-name{grid-column:2;grid-row:2;}
.status-badge{display:inline-block;padding:2px 8px;border-radius:999px;background:#f3f4f6;color:#333;font-weight:500;}
.status-success{background:#e8f7ed;color:#0a7f31;}
.status-strong{font-weight:700;}
table tr.order-row:hover td{background:#fffbe6;}
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;margin:18px 0;}
.stat-card{border:1px solid #ddd;border-radius:10px;padding:14px;background:#fafafa;}
.stat-title{font-size:13px;color:#666;margin-bottom:8px;}
.stat-value{font-size:28px;font-weight:700;line-height:1.2;}
.stat-sub{font-size:12px;color:#777;margin-top:6px;}
.report-grid{display:grid;grid-template-columns:1.35fr 1fr;gap:18px;align-items:start;}
.panel{border:1px solid #ddd;border-radius:10px;padding:14px;background:#fff;overflow:auto;}
.panel h3{margin-top:0;}
.chart-wrap{max-width:520px;margin:18px auto 0;}
@media (max-width: 1080px){.report-grid{grid-template-columns:1fr;}}
.inline-form{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
.inline-form input{min-width:120px;margin-right:0;}
.danger-btn{background:#b00020;color:#fff;border:1px solid #900;}
.danger-btn:hover{opacity:.92;cursor:pointer;}
.btn-link{display:inline-block;padding:6px 10px;border:1px solid #ddd;border-radius:6px;text-decoration:none;color:#333;background:#fff;}
.text-muted{color:#777;}
.cell-lines{display:flex;flex-direction:column;gap:4px;min-width:160px;}
.cell-line{line-height:1.45;word-break:break-word;}
.product-list{display:flex;flex-direction:column;gap:8px;min-width:280px;max-width:420px;overflow:hidden;}
.product-item{display:flex;gap:10px;align-items:flex-start;padding:6px 0;border-bottom:1px dashed #eee;max-width:420px;overflow:hidden;}
.product-item:last-child{border-bottom:none;}
.product-thumb{width:48px;height:48px;min-width:48px;max-width:48px;min-height:48px;max-height:48px;object-fit:cover;border:1px solid #ddd;border-radius:6px;background:#fff;display:block;overflow:hidden;}
.product-thumb-empty{display:flex;align-items:center;justify-content:center;color:#999;font-size:12px;}
.product-meta{display:flex;flex-direction:column;gap:2px;min-width:0;max-width:calc(100% - 58px);overflow:hidden;}
.product-name{font-weight:600;line-height:1.35;word-break:break-word;}
.orders-page .product-name a{text-decoration:none;}
.product-sub{font-size:12px;color:#555;line-height:1.35;}
table td{vertical-align:top;}

.domain-main{font-weight:700;word-break:break-all;}
.filters input[name="product_kw"]{min-width:180px;}
.filters select[name="country"]{min-width:120px;}
.product-name,.product-sub{overflow:hidden;text-overflow:ellipsis;}

.quick-links{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-top:4px;}
.quick-link{display:inline-flex;align-items:center;justify-content:center;min-width:26px;height:26px;padding:0 8px;border-radius:999px;text-decoration:none;font-size:12px;font-weight:700;line-height:1;border:1px solid transparent;transition:all .15s ease;box-sizing:border-box;}
.quick-link:hover{transform:translateY(-1px);box-shadow:0 2px 8px rgba(0,0,0,.08);}
.quick-link-visit{background:#ecfdf3;border-color:#b7ebc6;color:#0a7f31;}
.quick-link-visit:hover{background:#dff7e8;}
.quick-link-google{background:#eef4ff;border-color:#c8d8ff;color:#1a73e8;}
.quick-link-google:hover{background:#e3edff;}
.quick-link-gsc{background:#fff7e8;border-color:#ffd591;color:#ad6800;}
.quick-link-gsc:hover{background:#ffefdb;}

.panel-chart{margin:18px 0;}
.chart-wrap-wide{max-width:none;height:360px;}
.chart-wrap-wide canvas{width:100% !important;height:100% !important;}

.order-remark{margin-top:8px;padding:8px 10px;border-left:3px solid #f59e0b;background:#fff8e8;color:#7c4a03;font-size:12px;line-height:1.5;word-break:break-word;border-radius:6px;}
.filters input[name="remark_kw"]{min-width:180px;}
.chart-wrap-wide-half{max-width:none;height:320px;}
.chart-wrap-wide-half canvas{width:100% !important;height:100% !important;}

.remark-field-row{display:block;flex-basis:100%;width:100%;margin:8px 0;}
.remark-textarea{display:block;width:min(100%,980px);min-height:120px;resize:vertical;box-sizing:border-box;line-height:1.55;white-space:pre-wrap;word-break:break-word;}
.remark-display{white-space:pre-wrap;word-break:break-word;line-height:1.6;padding:10px 12px;background:#fff7cc;border:1px solid #f2d675;border-left:4px solid #e0a800;border-radius:6px;color:#6b4e00;font-weight:600;box-shadow:inset 0 0 0 1px rgba(255,215,0,.12);}
.orders-title-link{color:inherit;text-decoration:none;}
.orders-title-link:hover{text-decoration:underline;color:#111;}

.pagination{
  display:flex;
  gap:8px;
  align-items:center;
  margin:12px 0;
  flex-wrap:wrap;
}

.report-footer-links{display:grid;grid-template-columns:repeat(2,minmax(240px,1fr));gap:16px;margin:26px 0 8px;}
.report-link-card{display:flex;flex-direction:column;gap:6px;padding:18px 20px;border:1px solid #bfdbfe;border-radius:12px;background:linear-gradient(135deg,#eff6ff,#fff);color:#1e3a8a;text-decoration:none;transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease;}
.report-link-card:hover{transform:translateY(-2px);box-shadow:0 8px 22px rgba(37,99,235,.12);border-color:#60a5fa;}
.report-link-title{font-size:18px;font-weight:700;}
.report-link-desc{font-size:13px;color:#64748b;}
.report-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:12px 0 18px;}
.report-heading h2{margin:0 0 5px;}
.stat-value-compact{font-size:22px;overflow-wrap:anywhere;}
.report-note{margin:-2px 0 12px;}
.report-table{min-width:760px;}
.report-table th{white-space:nowrap;}
.metric-up{color:#0a7f31;font-weight:700;}
.metric-down{color:#b00020;font-weight:700;}
.rank-badge{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;padding:0 5px;border-radius:999px;background:#eef2f7;color:#475569;font-weight:700;box-sizing:border-box;}
.rank-1{background:#fef3c7;color:#92400e;}
.rank-2{background:#e2e8f0;color:#334155;}
.rank-3{background:#ffedd5;color:#9a3412;}
@media (max-width:700px){
  body{margin:12px;}
  .report-footer-links{grid-template-columns:1fr;}
  .report-heading{align-items:flex-start;flex-direction:column;}
  .stat-value{font-size:24px;}
}

.orders-nav-actions{display:flex;align-items:center;gap:8px;margin-left:auto;}
.orders-nav-actions .user-menu{margin-left:0;}
.theme-toggle{margin:0;padding:6px 10px;border:1px solid #d1d5db;border-radius:999px;background:#fff;color:#374151;cursor:pointer;font-size:12px;font-weight:700;line-height:1.2;}
.theme-toggle:hover{border-color:#94a3b8;background:#f8fafc;}

html[data-theme="dark"] body{background:#0f172a;color:#e5e7eb;}
html[data-theme="dark"] a{color:#93c5fd;}
html[data-theme="dark"] .orders-nav a{color:#e2e8f0;}
html[data-theme="dark"] .orders-nav a:hover{color:#60a5fa;}
html[data-theme="dark"] .nav-separator{color:#64748b;}
html[data-theme="dark"] .theme-toggle{background:#1e293b;color:#f8fafc;border-color:#475569;}
html[data-theme="dark"] .theme-toggle:hover{background:#334155;border-color:#64748b;}
html[data-theme="dark"] .user-menu[open] summary{background:#1e293b;}
html[data-theme="dark"] .user-menu summary::after{color:#94a3b8;}
html[data-theme="dark"] .user-menu-dropdown{background:#111827;border-color:#334155;box-shadow:0 10px 25px rgba(0,0,0,.45);}
html[data-theme="dark"] .user-menu-dropdown a:hover{background:#1e293b;}
html[data-theme="dark"] table th,
html[data-theme="dark"] table td{border-color:#334155;}
html[data-theme="dark"] th{background:#1e293b;}
html[data-theme="dark"] table tr.order-row:hover td{background:#263148;}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] button{background:#111827;color:#e5e7eb;border:1px solid #475569;border-radius:3px;}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder{color:#94a3b8;}
html[data-theme="dark"] pre,
html[data-theme="dark"] .box,
html[data-theme="dark"] .stat-card{background:#111827;border-color:#334155;}
html[data-theme="dark"] .panel{background:#111827;border-color:#334155;}
html[data-theme="dark"] .stat-title,
html[data-theme="dark"] .stat-sub,
html[data-theme="dark"] .text-muted{color:#94a3b8;}
html[data-theme="dark"] .btn-link{background:#1e293b;color:#e5e7eb;border-color:#475569;}
html[data-theme="dark"] .status-badge{background:#334155;color:#e5e7eb;}
html[data-theme="dark"] .status-success{background:#133b2a;color:#86efac;}
html[data-theme="dark"] .product-item{border-bottom-color:#334155;}
html[data-theme="dark"] .product-thumb{background:#1e293b;border-color:#475569;}
html[data-theme="dark"] .product-sub{color:#cbd5e1;}
html[data-theme="dark"] .order-remark{background:#3b2f13;color:#fde68a;}
html[data-theme="dark"] .remark-display{background:#3b3212;border-color:#786522;color:#fde68a;}
html[data-theme="dark"] .orders-title-link:hover{color:#f8fafc;}
html[data-theme="dark"] .quick-link-visit{background:#123524;border-color:#26653e;color:#86efac;}
html[data-theme="dark"] .quick-link-google{background:#172554;border-color:#274690;color:#93c5fd;}
html[data-theme="dark"] .quick-link-gsc{background:#3a2a10;border-color:#73510f;color:#fcd34d;}
html[data-theme="dark"] .report-link-card{background:linear-gradient(135deg,#172554,#111827);border-color:#334f8a;color:#bfdbfe;}
html[data-theme="dark"] .report-link-desc{color:#94a3b8;}
html[data-theme="dark"] .rank-badge{background:#334155;color:#e2e8f0;}
html[data-theme="dark"] .rank-1{background:#713f12;color:#fde68a;}
html[data-theme="dark"] .rank-2{background:#334155;color:#e2e8f0;}
html[data-theme="dark"] .rank-3{background:#7c2d12;color:#fed7aa;}
html[data-theme="dark"] .danger-btn{background:#991b1b;color:#fff;border-color:#ef4444;}

/* Compact orders list and viewport-positioned product preview. */
.orders-page{margin:12px;}
.orders-page h2{margin:8px 0;font-size:20px;}
.orders-page .nav{margin-bottom:6px;}
.orders-page .filters{display:flex;flex-wrap:wrap;gap:5px;margin:6px 0;align-items:center;}
.orders-page .filters input,.orders-page .filters select,.orders-page .filters button,.orders-page .sync input,.orders-page .sync button{margin-right:0;padding:4px 6px;}
.orders-page .btn-link{padding:4px 7px;}
.orders-page .sync{margin:6px 0;gap:6px;flex-wrap:wrap;}
.orders-page .orders-summary{margin:6px 0;}
.orders-page .pagination{margin:6px 0;}
.orders-page th,.orders-page td{padding:4px 6px;}
.orders-page .cell-lines{gap:2px;min-width:140px;}
.orders-page .cell-line{line-height:1.3;}
.orders-page .product-list{gap:4px;}
.orders-page .product-item{gap:7px;padding:3px 0;}
.orders-page .product-thumb{width:80px;height:80px;min-width:80px;max-width:80px;min-height:80px;max-height:80px;box-sizing:border-box;flex-shrink:0;}
.orders-page .product-meta{max-width:calc(100% - 87px);gap:1px;}
.orders-page .quick-links{gap:5px;margin-top:2px;}
.orders-page .quick-link{height:22px;min-width:22px;padding:0 6px;}
.orders-page .order-remark{margin-top:4px;padding:4px 6px;}
.orders-page .order-action{width:28px;text-align:center;white-space:nowrap;}
.orders-page .product-image-link{display:block;flex-shrink:0;cursor:zoom-in;}
.product-image-preview{position:fixed;z-index:1000;pointer-events:none;box-sizing:border-box;width:min(360px,calc(100vw - 24px),calc(100vh - 24px));height:min(360px,calc(100vw - 24px),calc(100vh - 24px));padding:8px;border:1px solid #d1d5db;border-radius:8px;background:#fff;box-shadow:0 8px 28px rgba(0,0,0,.24);}
.product-image-preview img{display:block;width:100%;height:100%;object-fit:contain;}
html[data-theme="dark"] .product-image-preview{background:#1e293b;border-color:#475569;}

.orders-page .domain-main a,.orders-page a[href^="mailto:"]{text-decoration:none;}
